我在根目录中有一个文件 index.php:
<?php
require_once "./include/common.php";
?>
和包含文件夹中的文件 common.php:
<?php
require_once "globalConfig.php";
?>
将 globalConfig 文件与 common.php 放在同一文件夹中。树文件夹为:
xxx/index.php
xxx/include/common.php
xxx/include/globalConfig.php
index.php 运行正常。但是,如果我将文件 common.php 更改为:
<?php
require_once "./globalConfig.php";
?>
PHP 显示一个警告,它找不到 globalConfig.php 文件。有什么区别?我认为在“./”的情况下,最外部的包含文件(index.php)将在其当前目录中找到 globalConfig.php。