Re: [patch] re-invoking default error handler

From: Date: Thu, 27 May 2004 18:49:30 +0000
Subject: Re: [patch] re-invoking default error handler
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-10118@lists.php.net to get a copy of this message
On Thu, May 27, 2004 at 08:50:48AM -0700, Andrei Zmievski wrote: > Attached is a small patch that can let you do the following. If you set > a custom error handler via set_error_handler() but don't want to > implement all the details of handling every single error level, now you > can simply handle the ones you are interested. Basically, if you return > 1 from your error handler, then the PHP default error handler gets > invoked, otherwise nothing happens. So: > > function my_notice_handler($type, $str, $file, $line, $context) > { > if ($type == E_NOTICE || $type == E_USER_NOTICE) { > /* do something */ > return false; > } else { > /* let PHP default handler do it */ > return true; > } > } The convention(*) for these kinds of things is generally to return 'true' when you've handled the message/event and want to discontinue further processing. Returning 'false' indicates that you haven't handled the event. (*) I don't mean "PHP covention", but this is how most other messaging systems work when chaining handlers. > It's backwards compatible with previous functionality, i.e. if you don't > return anything, the default handler does not get invoked. This argument may overrule my preference, of course. -- Jon Parise (jon@php.net) :: The PHP Project (http://www.php.net/)

« previous php.internals (#10118) next »