Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adds support for multiple error handlers in PHP
<?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);
}
}
});
}
@gcd2510

This comment has been minimized.

Copy link

gcd2510 commented Feb 20, 2017

Can you explain a little bit about 3 function??. i cant understand what they do. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.