When using Yii as an image server, you often need to deal with absolute paths.
(Recommended tutorial: yii)
First of all, you need to know what the root directory of the website is.
There are the following 3 methods:
1. Use dirname(__FILE__) in the index.php file and save it
2. Use Yii::app()- >basePath, this points to the protected directory, just go back one level: Yii::app()->basePath.'/../'
3. Use Yii::getPathOfAlias ('webroot').'/'
The above is the detailed content of How to get the website root directory in Yii. For more information, please follow other related articles on the PHP Chinese website!