Home > PHP Framework > YII > body text

How to get the website root directory in Yii

王林
Release: 2020-10-14 17:37:49
forward
2639 people have browsed it

How to get the website root directory in Yii

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!

Related labels:
yii
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!