How can error_reporting be used to debug file access issues in PHP?

When encountering file access issues in PHP, error_reporting can be used to display any errors or warnings related to file operations. By enabling error_reporting, developers can easily identify the root cause of the problem, such as incorrect file permissions or missing files. This can help in debugging and resolving file access issues efficiently.

// Enable error reporting to display any file access errors
error_reporting(E_ALL);

// Code snippet demonstrating file access
$file = 'example.txt';

// Check if file exists
if (file_exists($file)) {
    // Attempt to read the file
    $content = file_get_contents($file);
    echo $content;
} else {
    echo "File does not exist.";
}