据我所知,PHP的
如果当前目录恰好是另一个目录的符号链接,则PHP(可能与Apache一起)应该返回显示符号链接名称作为您所在的“目录”的路径。
例如:
getcwd()
(以及类似的函数,如dirname(__FILE__)
)应该返回正在执行文件的当前目录。如果当前目录恰好是另一个目录的符号链接,则PHP(可能与Apache一起)应该返回显示符号链接名称作为您所在的“目录”的路径。
例如:
from /var/www,
directory 'one' contains index.php
symlink 'two' points at directory 'one'
one/index.php: <?php echo getcwd(); ?>
在浏览器中访问http://localhost/two/index.php,显示的是/var/www/one
。
我期望它应该显示/var/www/two
。
请问这是可以通过更改PHP或Apache设置来实现吗?还是我无法以这种方式使用符号链接?
Options FollowSymLinks
- Jérôme Mahuetmkdir a; ln -s a b; php -r 'chdir( "b" ); echo getcwd();'
,PHP将向您显示您位于名为“a”的目录中,即使您已经使用chdir()进入了“b”目录。 - edam