What are the common errors that can occur when checking for the existence of a directory using is_dir in PHP?

One common error that can occur when checking for the existence of a directory using is_dir in PHP is not providing the correct path to the directory. This can result in the function returning false even if the directory actually exists. To solve this issue, make sure to provide the correct path to the directory when using is_dir.

$directory = '/path/to/directory';

if (is_dir($directory)) {
    echo 'Directory exists';
} else {
    echo 'Directory does not exist';
}