php is_dir 判断中文目录失败,PHP: is_dir - Manual

在运行PHP5.2.0的Apache Windows环境中,遇到一个目录权限问题,is_dir函数对于某些具有特定权限的目录返回False,即使这些目录实际上是可访问的。通过提供更完整的路径,问题得到了解决。例如,当只使用相对路径时,大约1/3的子目录会受到影响。但是,当在每次迭代中加入完整路径时,is_dir函数能正确识别所有目录。这是一个可能帮助其他遇到相同问题的解决方案。
摘要由CSDN通过智能技术生成

Running PHP 5.2.0 on Apache Windows, I had a problem (likely the same one as described by others) where is_dir returned a False for directories with certain permissions even though they were accessible.

Strangely, I was able to overcome the problem with a more complete path. For example, this only displays "Works" on subdirectories with particular permissions (in this directory about 1 out of 3):

$d = opendir("./albums/mydir");

while(false !== ($f = readdir($d))) {

echo "


";

if(is_dir($f)) {

echo "Works:" . $f . "";

}

}

However, this works properly for all directories:

$d = opendir("./albums/mydir");

while(false !== ($f = readdir($d))) {

echo "


";

$dName = "./albums/mydir/" . $f;

if(is_dir($dName)) {

echo "Works:" . $dName . "";

}

}

I don't understand the hit-and-miss of the first code, but maybe the second code can help others having this problem.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值