User Contributed Notes 15 notes

Just a note for anyone who encounters is_dir() returning false on CIFS mount points or directories within those mount points on 2.6.31 and newer kernels: Apparently in new kernels they've started using the CIFS serverino option by default. With Windows shares this causes huge inode numbers and which apparently can cause is_dir() to return false. Adding the noserverino option to the CIFS mount will prevent this. This may only occur on 32 systems but I don't have a 64 bit install to test against.

One note regarding checking for empty directories :>>echo (count(glob("$dir/*")) === 0) ? 'Empty' : 'Not empty';This does not work correctly on Linux.The '.' and '..' will always be returned even if no files are present in the directory.

NOTE: you should obviously be checking beforehand if $dir is actually a directory, and that it is readable, as only relying on this you would assume that in both cases you have a non-empty readable directory.

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):