What potential pitfalls should be considered when using file_exists() function in PHP to check for file existence?

When using the file_exists() function in PHP to check for file existence, it's important to consider that the function may return false positives if the file permissions are not set correctly or if the file path is incorrect. To avoid this issue, it's recommended to also check if the file is readable using the is_readable() function before proceeding with any operations on the file.

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

if (file_exists($file_path) && is_readable($file_path)) {
    // File exists and is readable, proceed with operations
    // For example, read the file contents or perform other actions
} else {
    // Handle the case where the file does not exist or is not readable
}