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.
source share