Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10118 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87231 invoked by uid 1010); 27 May 2004 18:49:31 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 87169 invoked from network); 27 May 2004 18:49:31 -0000 Received: from unknown (HELO blacksheep.csh.rit.edu) (129.21.60.6) by pb1.pair.com with SMTP; 27 May 2004 18:49:31 -0000 Received: from fury.csh.rit.edu (fury.csh.rit.edu [IPv6:2001:470:1f00:135:a00:20ff:fe8d:5399]) by blacksheep.csh.rit.edu (Postfix) with ESMTP id 0BD259D8B for ; Thu, 27 May 2004 14:49:31 -0400 (EDT) Received: by fury.csh.rit.edu (Postfix, from userid 37404) id D8EE5145C; Thu, 27 May 2004 14:49:30 -0400 (EDT) Date: Thu, 27 May 2004 14:49:30 -0400 To: internals@lists.php.net Message-ID: <20040527184929.GB23166@csh.rit.edu> Mail-Followup-To: internals@lists.php.net References: <20040527155047.GA36904@gravitonic.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040527155047.GA36904@gravitonic.com> Subject: Re: [PHP-DEV] [patch] re-invoking default error handler From: jon@php.net (Jon Parise) 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/)