Home  >  Article  >  Backend Development  >  PHP中相对路径的解决方法

PHP中相对路径的解决方法

WBOY
WBOYOriginal
2016-06-13 11:00:151349browse

PHP中相对路径的解决办法
在PHP中require,include一个文件时,我用的大都是相对路径,只是在包含文件之前,先包含一个global.php文件。这个文件的内容是:

<?phpchdir(dirname(__FILE__));?>

,它的作用是将当前目录切换到global.php所在的路径。
将global.php放在根目时录下,在这之后包含的所有文件就会以根目录为基准了。

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