我有这样的功能:is_dir不识别目录。为什么?
if (is_dir($dir)) {
//are we able to open it?
if ($dh = opendir($dir)) {
//Let's cycle
while (($subdir = readdir($dh)) !== false) {
if ($subdir != "." && $subdir != "..") {
echo $subdir;
}
}
}
这将返回:
directory1 , directory2, directory3 etc.. etc..
Hoever如果我这样做:
if (is_dir($dir)) {
//are we able to open it?
if ($dh = opendir($dir)) {
//Let's cycle
while (($subdir = readdir($dh)) !== false) {
if ($subdir != "." && $subdir != "..") {
if (is_dir($subdir)) {
echo $subdir;
}
}
}
}
它不打印什么!
为什么会发生这种情况? 我使用Windows和XAMPP运行脚本进行测试。该目录实际上包含目录。
谢谢
*(相关)* http://stackoverflow.com/questions/2418068/php-spl -recursivedirectoryiterator-recursiveiteratoriterator-检索 - 在全/ 2655620#2655620 – Gordon 2010-04-19 10:13:21