In Yii, if yes//will default to the protected/views/layouts,//to represent the absolute path. This is actually the absolute and relative relationship/representing the relative path, such as layout under Module/user. Using a single slash, the default is to find the currently activated module under the view, if the current module is not active from the system root directory to find, double slash words directly from the system root to find
The YII framework has defined namespace constants:
system: Point to the YII framework directory; Yii\framework
zii: Point to zii Library directory; Yii\framework\zii
application: Point to the application base directory; protected\
Webroot: Point to the directory containing the inside portal script file. This alias is valid from version 1.0.3. \
ext: Point to the directory containing all third-party extensions, available from version 1.0.8; \protected\extensions
Yii::getpathofalias (' zii ') yii::import (' zii.* ') yii::setpathofalias (' backend ', $backend); ' Import ' = = Array (' backend.models.* ',
The application's home directory is the root directory of PHP code and data that contains all the higher safety factors. By default, this directory is usually a directory in the directory where the entry code is located: protected. This path can be changed by setting BasePath in the application configuration.
YII Framework Path:
Yii::getframeworkpath () {Full URL}
Protected/venders directory:
Yii::import (' application.venders.* ');
or in protected/config/main.php description:
' Import ' =>array (... ') Application.venders.* ',
Insert Meta Information:
Yii::app ()->clientscript->registermetatag (' keywords ', ' keywords '); Yii::app ()->clientscript->registermetatag (' description ', ' some descriptions '); Yii::app ()->clientscript->registermetatag (' author ', ' author ');
Add a CSS file or JavaScript file to the controller:
Call the Framework/web/js/source JS in the Yii framework, where the file Registercorescript key is called in the framework/web/js/packages.php list to see:
Get the ID method of the current controller in view:
Yii::app ()->getcontroller ()->id;
Get the ID method of the current action in view:
Yii::app ()->getcontroller ()->getaction ()->id;
Yii Get IP Address
Yii Judgment Submission Method
Yii::app ()->request->ispostrequest
Get the current domain name:
Get the physical path to the proteced directory
Get the URL of the previous page to return
Get current URL
Get the current home URL
Get the current return URL
Project path
If you own a directory where some classes or files are commonly used, you can define a path alias at the top of the main.php, and the alias can be translated to its corresponding path.
Yii::getpathofalias (' Webroot ')
If more than one configuration can be added to an array in the main.php
' Aliases ' =>array (' local ' = ' path/to/local/'), <?php echo $this->getlayoutfile (' main ');?> $this Redirect (' Index.php?r=admin/manage '); {CreateURL ()}echo $this->createurl (' urlboyleetest '); out =/yii_lab/index.php?r=lab/urlboyleetest $this->createurl (' post/read ')///index.php/post/read <?php Echo Yii::app ()->request->baseurl; >/css/screen.css Yii::app ()->theme->baseurl. ' /images/filename.gif '