-
-
Save lyoshenka/9840853 to your computer and use it in GitHub Desktop.
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