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

PHP中相对路径的解决方法

WBOY
Release: 2016-06-13 11:00:15
Original
1405 people have browsed it

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

<?phpchdir(dirname(__FILE__));?>
Copy after login

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

Related labels:
source:php.cn
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