In the context of PHP, how can the existence of a file be checked before performing operations on it?

To check the existence of a file in PHP before performing operations on it, you can use the `file_exists()` function. This function returns true if the file exists and false if it does not. By checking the existence of the file before performing operations, you can avoid errors and handle the situation appropriately.

$filename = 'example.txt';

if (file_exists($filename)) {
    // Perform operations on the file
    echo "File exists!";
} else {
    echo "File does not exist.";
}