What are common pitfalls when using file_exists in PHP code?

Common pitfalls when using `file_exists` in PHP code include not checking for file permissions, not handling symbolic links properly, and not considering the impact of open_basedir restrictions. To avoid these issues, always check if the file exists and if the script has the necessary permissions to access it.

$filename = 'example.txt';

if (file_exists($filename) && is_readable($filename)) {
    // File exists and is readable, proceed with accessing the file
    $file_contents = file_get_contents($filename);
    echo $file_contents;
} else {
    // Handle the case when the file does not exist or is not readable
    echo "File does not exist or is not readable.";
}