If our current page's access address is: http://localhost/CMS/public/index.php?
R=news&id=1
One,
1, get the current domain name: Echoyii::app ()->request->hostinfo;
Result: http://localhost
2, gets (except for the domain name) the current Url:echoyii::app ()->request->geturl ();
Result:/cms/public/index.php?r=news&id=1
3, get (except for the domain name) home address: Echoyii::app ()->user-> RETURNURL;
Result:/cms/public/index.php
4, get (except for the domain name) root folder address: Echoyii::app ()->homeurl;
Result:/cms/public/index.php
5, Echoyii::app ()->request->baseurl;
Result:/cms/public
6, get the site root folder relative address: Echo Yii::app ()->baseurl;
Result:/cms/public (Note: If you are using this method to point to the site root folder, it is best to add a "/" after it, because it is sometimes assumed that you do not join "/", it may not be correct to point to the site root folder.) Application Example: <ahref= "<?
php echo Yii::app ()->baseurl;? >/">Home</a>)
Two
7,Yii get IP Address:yii::app ()->request->userhostaddress;
8. Yii Inference Submission Method: Yii::app ()->request-ispostrequest;
9. Physical path of proteced folder: Yii::app ()->basepath;
10. Get the URL of the previous page to return: Yii::app ()->request->urlreferrer;
11. Get current controller Id:yii::app ()->getcontroller ()->getaction ()->id;
12, Project path: DirName (Yii::app ()->basepath);
13, Yii get get,post come over data: Yii::app ()->request->getparam (' id ');
Three
14, Yii How to set the time zone:
Able to set time zones in config/main.php ' timeZone ' = ' asia/chongqing '
15, Prevent repeated submission:Ccontroler->refresh ();
16, call the YII Framework Jquery:yii::app ()->clientscript->registercorescript (' jquery ');
17. Project Path: DirName (Yii::app ()->basepath)
Yii gets the current URL and domain name