How can one customize error messages when including files in PHP?

To customize error messages when including files in PHP, you can use the `set_error_handler()` function to define a custom error handler. Within this custom error handler, you can check for errors related to file inclusion and then output a custom error message as needed.

function customErrorHandler($errno, $errstr, $errfile, $errline) {
    if (strpos($errstr, 'require') !== false || strpos($errstr, 'include') !== false) {
        echo "Custom error message: File inclusion error occurred";
    } else {
        // Handle other types of errors
    }
}

set_error_handler("customErrorHandler");

include 'non_existent_file.php'; // This will trigger the custom error message