I am trying to replace the built in php shutdown_function with a custom one.
It works perfectly, however, it still outputs the original error (built in error) above my new error message.
<?php
function shutdown_output() {
$error = error_get_last();
if($error !== NULL) {
echo "ERROR";
exit();
} else {
echo "NO ERROR";
}
}
// Set the error reporting:
register_shutdown_function('shutdown_output');
// test.php does not exist, just here to get a critical error
require_once("test.php");
?>
Any ideas?
As already mentioned in comments, the use of register_shutdown_function
is not going to override built-in error handling (the same way that set_error_handler
doesn't either).
If you don't want to see the original message, disable the output of them in your php.ini
using display_errors = 0
. Or on the fly in your script using ini_set('display_errors', 0);
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With