Php Opendir仅适用于绝对路径
使用以下代码时:Php Opendir仅适用于绝对路径,php,path,warnings,opendir,Php,Path,Warnings,Opendir,使用以下代码时: if ($handle = opendir('../flat')) { } 我得到了这个错误: Warning: opendir(../flat) [function.opendir]: failed to open dir: No such file or directory in D:\Inetpub\webs\mysite\newSite\lib\flat.php on line 1 使用 我可以看到PHP脚本的正确路径: D:\Inetpub\webs\mysit
if ($handle = opendir('../flat')) {
}
我得到了这个错误:
Warning: opendir(../flat) [function.opendir]: failed to open dir: No such file or directory in D:\Inetpub\webs\mysite\newSite\lib\flat.php on line 1
使用
我可以看到PHP脚本的正确路径:
D:\Inetpub\webs\mysite\newSite\lib
使用绝对路径opendir
效果良好:
if ($handle = opendir('D:\Inetpub\webs\mysite\newSite\flat')) {
}
有什么问题吗?有人能帮我吗?PHP的open dir函数不能处理URL,除非它们是完全的和绝对的。您的相对路径不能与open dir一起使用,除非它是文件目录或绝对路径,如 根据PHP: a) path支持ftp://URL包装器
b) 路径也可以是支持目录列表的任何URL,但是在PHP4中,只有file://URL包装器支持这一点使用一个显式相对于脚本目录的路径:
dirname(\uuuu file\uuu)。目录分隔符“/扁平'
。
if ($handle = opendir('D:\Inetpub\webs\mysite\newSite\flat')) {
}