Created
May 30, 2013 13:53
-
-
Save gcatlin/5677984 to your computer and use it in GitHub Desktop.
Adds support for multiple error handlers in PHP
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 | |
function append_error_handler($handler) { | |
set_error_handlers(array(set_error_handler($handler), $handler)); | |
} | |
function prepend_error_handler($handler) { | |
set_error_handlers(array($handler, set_error_handler($handler))); | |
} | |
function set_error_handlers($handlers) { | |
$handlers = (is_array($handlers) ? $handlers : array($handlers)); | |
set_error_handler(function ($level, $message, $file = null, $line = null, $context = null) use ($handlers) { | |
foreach ($handlers as $handler) { | |
if ($handler) { | |
call_user_func($handler, $level, $message, $file, $line, $context); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you explain a little bit about 3 function??. i cant understand what they do. Thanks