Register_shutdown_function () still displays the original error message

I am trying to replace the built-in php shutdown_function with a custom one.

It works fine, however, it still displays the original error (built-in error) over 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?

+6
source share
1 answer

As mentioned in the comments, using register_shutdown_function will not cancel the built-in error handling (just like set_error_handler ).

If you do not want to see the original message, disable the output from them in php.ini using display_errors = 0 . Or on the fly in a script using ini_set('display_errors', 0); .

+3
source

All Articles