In most situations when encountering an unexpected condition within a script it is better to stop execution rather then allowing script to proceed potentially causing further errors and complicating debugging process.


To help simplify the process PHP has a trigger_error() function that can be used to both log the error to the error log as well as terminate execution if need be.

<?php
if (!($fp = @fopen("some_file""r"))) {
    
trigger_error("Failed to open 'some_file'"E_USER_ERROR);
}
?>