从包含的文件调用包含
因此,检查此目录结构
- /include_one.php
- /include_two.php
- /目录/main_file.php
假设我在 /directory/main_file.php,我在 include_one.php 内部调用,以包含include_two.php。我需要打电话还是?include('../include_one.php');
include('include_two.php);
include('../include_two.php');
所以我的问题是:当包含文件时,“相对包含路径”是转移到包含的文件,还是保留在主包含文件?
我知道最好的选择是有一个包含root_path.php配置,但是在这个阶段这是不可能的。
更新:
所以,我不确定谁是对的,因为这是我的测试
目录结构
/include.php
/start/start.php
/folder1/includeone.php
/folder1/folder2/includetwo.php
这是每个文件的内容
开始.php
<?php
echo 'including ../include.php<br />';
include('../include.php');
?>
包括.php
<?php
echo 'including folder1/includeone.php<br />';
include('folder1/includeone.php');
?>
包括一个.php
<?php
echo 'including folder2/includetwo.php<br />';
include('folder2/includetwo.php');
?>
包括两个.php
<?php
echo 'done<br />';
?>
并且输出为
包括。。/include.php
include folder1/includeone.php
include folder2/includetwo.php
完成