为什么此PHP相对包含失败?

|
disc@puff:~/php$ ls 
a.php  data  include 

disc@puff:~/php$ tree 
. 
├── a.php 
├── data 
│   └── d.php 
└── include 
    ├── b.php 
    └── c.php 
2 directories, 4 files 

disc@puff:~/php$ cat a.php 
a.php is including include/b.php ... 
<?php include \"include/b.php\" ?> 

disc@puff:~/php$ cat include/b.php 
b.php is including c.php and ../data/d.php ... 
<?php include \"c.php\" ?> 
<?php include \"../data/d.php\" ?> 

disc@puff:~/php$ cat include/c.php 
c.php 

disc@puff:~/php$ cat data/d.php 
d.php 

disc@puff:~/php$ php a.php 
a.php is including include/b.php ... 
b.php is including c.php and ../data/d.php ... 
c.php 
PHP Warning:  include(../data/d.php): failed to open stream: No 
such file or directory in /home/disc/php/include/b.php on line 3 
PHP Warning:  include(): Failed opening \'../data/d.php\' for 
inclusion (include_path=\'.:/usr/share/php:/usr/share/pear\') in /home/ 
disc/php/include/b.php on line 3 

disc@puff:~/php$ 
为什么“ 1”成功但“ 2”失败? http://www.php.net/manual/zh/function.include.php提到:\“如果有路径 定义-绝对值(以驱动器号或\\开头 Windows,或/(在Unix / Linux系统上)或相对于当前版本 目录(以。或..开头)— include_path将被忽略 共。例如,如果文件名以../开头,则解析器 将在父目录中查找以找到请求的文件。 \“ 父目录是什么?     
已邀请:
        路径总是相对于被调用的脚本。在您的示例中,加载c.php是因为\“。\”(当前目录)始终位于include_path中。 要解决此问题,您可以使用
dirname(__FILE__)
始终知道文件本身的目录。 (您在其中写入FILE的文件) 或者您可以使用
dirname($_SERVER[\'SCRIPT_FILENAME\'])
来获取校准脚本的目录。     
        从
a.php
开始时,应在
a.php
中定义include目录:
define(\'MY_INCLUDES\', dirname(__FILE__) . \'/include/\');
define(\'MY_DATA\', dirname(__FILE__) . \'/data/\');
然后包括具有绝对路径的文件:
include(MY_INCLUDES . \'b.php\');
include(MY_DATA . \'c.php\');
    

要回复问题请先登录注册