Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyoshenka/9840853 to your computer and use it in GitHub Desktop.
Save lyoshenka/9840853 to your computer and use it in GitHub Desktop.
<?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