Determining if a Path is a File

Problem

You want to check if a file path is a file.

Solution

Use the File::isFile() method.

if (File::isFile($filename))
{
    echo "Yep. It's a file.";
}

If the file exists and is a regular file then true is returned. Otherwise false is returned.

Discussion

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

comments powered by Disqus