What are best practices for handling file existence checks in PHP scripts to avoid errors or unexpected behavior?

When checking for file existence in PHP scripts, it's important to handle potential errors and unexpected behavior that may arise. One best practice is to use the `file_exists()` function to check if a file exists before attempting to perform any operations on it. Additionally, it's recommended to use absolute file paths to avoid issues with relative paths. Finally, consider implementing error handling mechanisms, such as try-catch blocks, to gracefully handle any exceptions that may occur during file existence checks.

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

if (file_exists($file_path)) {
    // File exists, perform operations
    $file_contents = file_get_contents($file_path);
    echo $file_contents;
} else {
    // File does not exist, handle accordingly
    echo "File does not exist.";
}