Created
January 30, 2013 11:26
-
-
Save lastguest/4672628 to your computer and use it in GitHub Desktop.
Chain-in a new PHP error_handler not destroying the old one.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_error_handler(function(){ echo "INTERNAL\n"; }); | |
function chain_error_handler($new_handler){ | |
$old_handler = set_error_handler(function() use (&$old_handler,$new_handler){ | |
call_user_func_array($new_handler,func_get_args()); | |
call_user_func_array($old_handler,func_get_args()); | |
}); | |
} | |
chain_error_handler(function(){ echo ":D\n"; }); | |
$a = 1/0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment