What is the correct way 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 returns true if the specified file path is a directory, otherwise it returns false. You can use this function to determine if a file is a directory before performing any directory-specific operations.

$filePath = 'path/to/your/file';

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