custom error handler that would take effect only in my class?
Or do I must call set_error_handler()
on beginning开发者_开发知识库 and restore_error_handler()
on end of every of my methods ?
Not necessarily.
When your error handler returns false, it will continue to the next registered error handler. (usually the php default error handler).
So you could write your function in a way it only handles specific - custom written - error codes.
function newErrorHandler($errno, $errstr, $errfile, $errline) {
if (checkIfyours) {
// Do something.
}
return false;
}
精彩评论