What function can be used to check if a file is a directory in PHP?

To check if a file is a directory in PHP, you can use the is_dir() function. This function takes a file path as an argument and returns true if the file is a directory, and false otherwise. You can use this function to determine if a specific file is a directory before performing any operations on it.

$file_path = 'path/to/file/or/directory';

if (is_dir($file_path)) {
    echo "The file is a directory.";
} else {
    echo "The file is not a directory.";
}