Home >Backend Development >PHP Tutorial >Explanation of dirname(_file_) in PHP_PHP Tutorial

Explanation of dirname(_file_) in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:56:23750browse

It is usually very effective to use dirname(__FILE__) when configuring the file path. However, because the path of __FILE__ is the full path of the file where the current code is located (not the file where the url is located), the defined configuration file is usually placed in the root directory. Define the root address of the website, but the following method can solve the problem of storing the configuration file.
dirname(dirname(__FILE__)); /*
Assume __FILE__ is /home/web/config/config.php
The output of the above method is /home/web
*/
dirname(dirname(__FILE__)); What you get is the name of the directory above the file
dirname(__FILE__); What you get is the name of the directory where the file is located

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318123.htmlTechArticleUsually using dirname(__FILE__) when configuring the file path is a very effective method, but because of __FILE__ The path is the full path to the file where the current code is located (not the file where the url is located),...
Statement:
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