Is a custom PHP error handler respected for setting up PHP?

I would be happy if someone could explain the PHP error handling architecture to me. Some specific questions:

  • At what stage does the default error handler look at the appropriate PHP configuration parameters?
  • Does the custom error handler execute these parameters completely?
  • How can I customize my own error handler regarding configuration?
+4
source share
1 answer

This is pretty much how you suspect. A custom error handler should check all settings and respond appropriately.

The set_error_handler example first checks the current level of the active error and compares it with the first callback parameter (bitwise and), which indicates the current error Type:

if (!(error_reporting() & $errno)) { 

But for initial testing, if you really have to print errors, you will also need:

 ini_get("display_errors") or return; 

Or respond to more settings and emulate a default error handler, even ini_get("html_errors") , etc. If you do not do all this manually, your user error handler will display all errors. They are not filtered, the callback receives everything.


The default PHP error handler is php_error_cb around line 850 here:
http://svn.php.net/viewvc/php/php-src/trunk/main/main.c?revision=309647&view=markup#855

This is a bit more, but also asks for the ini registry. That error_reporting always saves the current state.

+4
source

All Articles