How can one effectively test if the source file can be opened in PHP?

To effectively test if a source file can be opened in PHP, you can use the `file_exists()` function to check if the file exists and the `is_readable()` function to check if the file is readable. These functions will help determine if the file can be successfully opened in PHP.

$sourceFile = 'example.txt';

if (file_exists($sourceFile) && is_readable($sourceFile)) {
    // Open the file and perform operations
    $fileHandle = fopen($sourceFile, 'r');
    
    // Read the contents of the file
    $fileContents = fread($fileHandle, filesize($sourceFile));
    
    // Close the file
    fclose($fileHandle);
    
    // Output the file contents
    echo $fileContents;
} else {
    echo 'Unable to open or read the file.';
}