Determining if a Path is a Directory

Problem

You want to check if a filepath is a directory.

Solution

Use the File::isDirectory() method.

if (File::isDirectory($filename))
{
    echo "Yes. It's a directory.";
}

If the path exists and is a directory true is returned. Otherwise false is returned.

Discussion

This is a simple wrapper on the PHP is_dir() function.

comments powered by Disqus