【发布时间】:2012-04-01 23:27:23
【问题描述】:
我的网络文件夹中有几个文件,包括这两个:
- /mydocroot/include/somesubdir/include.inc.php
- /mydocroot/include/settings.inc.php
其中 somesubdir 是指向我磁盘上另一个目录的符号链接,指向名为的路径,嗯,比如说 /anywhere/else。
在include.inc.php里面,写了这样的东西:
<?php
require_once "../settings.inc.php";
?>
在我看来,应该包含 /mydocroot/include/settings.php...但是猜猜会发生什么:PHP 试图包含 /anywhere/ settings.inc.php,而不是 /mydocroot/include/settings.inc.php。
似乎 PHP 会自动解析符号链接。
如何避免这种情况并包含我的 settings.inc.php 文件?
【问题讨论】:
-
echo __DIR__;里面的/include.inc.php打印什么? -
@Rocket:
echo __DIR__;打印/anywhere/else。