我在根目录下的index.php文件问题:PHP需要与 “./”
<?php
require_once "./include/common.php";
?>
,并在文件中的common.php包括文件夹:
<?php
require_once "globalConfig.php";
?>
文件globalConfig在同一common.php文件夹。树文件夹:
XXX/index.php文件
XXX /包括/的common.php
XXX /包括/ globalConfig.php
index.php的正常运行。但是,如果我更改文件的common.php为:
<?php
require_once "./globalConfig.php";
?>
PHP显示一个警告,它无法找到globalConfig.php文件。有什么不同?我认为在“./”的情况下,最外面的包含文件(index.php)会在当前目录中找到globalConfig.php。
另请参阅http://stackoverflow.com/questions/1395909/php-include-all-paths-get-messed-up,http://stackoverflow.com/questions/3429780/include-and-path-problem ,以及搜索“php包含路径”的其他许多问题:) – 2010-09-07 10:43:09