is_dir无法识别目录.为什么?

0pl*_*us1 4 php directory readdir

我有这个功能:

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;

                }
        }
}
Run Code Online (Sandbox Code Playgroud)

返回:

directory1 , directory2, directory3 etc.. etc..
Run Code Online (Sandbox Code Playgroud)

无论如何,如果我这样做:

    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;
                    }

                }
        }
}
Run Code Online (Sandbox Code Playgroud)

它什么都不打印!

为什么会这样?我正在运行带有Windows和XAMPP的脚本以进行测试.该目录实际上包含目录.

谢谢

bin*_*yLV 11

is_dir($dir . '/' . $subdir)