What potential pitfalls should be considered when verifying the presence of a file in PHP?

One potential pitfall when verifying the presence of a file in PHP is not properly handling file paths. It's important to sanitize user input to prevent directory traversal attacks. Additionally, file permissions should be considered to ensure that the file is readable.

$file_path = '/path/to/file.txt';

// Sanitize file path
$file_path = realpath($file_path);

if ($file_path && is_file($file_path) && is_readable($file_path)) {
    echo 'File exists and is readable.';
} else {
    echo 'File does not exist or is not readable.';
}