Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: set_error_handler(): duplicate error Date: Sun, 20 Jun 2021 13:10:28 +0200 Lines: 87 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Trace: individual.net kvS+/4g5eOebn9eg9pC9DwyoNK/f8kxoEEbBGtUtWR0EIkXmK1 Cancel-Lock: sha1:gj0qD+vVO5m+Cy2hvWWgsGC5sDc= In-Reply-To: Xref: csiph.com comp.lang.php:18667 Jerry Stuckle: > On 6/19/2021 10:41 AM, alex wrote: >> Il 19/06/21 04:00, Jerry Stuckle ha scritto: >>> >>> set_error_handler() requires a real function as its parameter, not >>> something dynamically defined. >> >> class C { >>     static function f($severity, $message) { >>         throw new InternalErrorException($message); >>     } >> } >> >> set_error_handler('C::f'); >> >> xxx(); >> >> Output >> >> Fatal error: Uncaught Error: Call to undefined function xxx() in >> /tmp/tmp.F06vf0Q7H0/test.php on line 10 >> >> Error: Call to undefined function xxx() in /tmp/tmp.F06vf0Q7H0/test.php >> on line 10 >> >> Call Stack: >>     0.0001     394552   1. {main}() /tmp/tmp.F06vf0Q7H0/test.php:0 >> >> > > Normal operation. See the restrictions under set_error_handler(), namely > > "The following error types cannot be handled with a user defined > function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, > E_COMPILE_ERROR, E_COMPILE_WARNING independent of where they were > raised, and most of E_STRICT raised in the file where > set_error_handler() is called. " Thanks for pointing this out. Also see: This means, if such an error ocurrs - like calling an undefined function - it will *not* be passed to the handler defined in set_error_handler(). So this works: ------------------------------