The php Function is_dir
The php function is_dir lets you verify if a given path name is a directory. This is especially useful when it comes to parsing file paths or iterating through directories, but it can also be used for checking whether a particular path is a regular file, a symlink, or an unknown type of file (as a note, this method does not check whether a file actually exists; you would need to use is_file() or file_exists() to do that).
The is_dir() function accepts one parameter - the file path to be checked. The returned bool value is true if the path is a directory, and false otherwise. The function also follows symlinks, so you should always supply the full path to the directory in which the symlink is located.
If you are using open_basedir, the is_dir() function may be slower than it would be if you didn't have this feature enabled. Also, the is_dir() function results are cached; use clearstatcache() to clear them.
In a performance test, is_dir was found to be at least four times faster than file_exists in determining whether the path is a directory; however, it may take longer depending on the depth of the folder being examined. You should use is_dir() if you are trying to optimize your scripts for speed, but remember that this method does not check whether the path is valid, so you would need to combine it with the is_file() or file_exists() functions to do that.