Re: [patch] re-invoking default error handler
| From: | Bert Slagter | Date: | Fri, 28 May 2004 07:40:51 +0000 |
| Subject: | Re: [patch] re-invoking default error handler | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals php.internals |
| Request: | Send a blank email to internals+get-10139@lists.php.net to get a copy of this message | ||
Derick Rethans wrote:
On Fri, 28 May 2004, Bert Slagter wrote: E_STRICT can not be handled you say, can you give a small example script on that? regards, DerickOf course :) ----------- <?php Foo::bar(); $Foo->foo = 0; class Foo { var $baz; function bar() { } } class Foo2 extends Foo { function bar($param1) { } } ?> ----------- This piece of sh.. erm code produces 4 E_STRICT errors: ----------- Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in test2.php on line 6 Strict Standards: Declaration of Foo2::bar() should be compatible with that of Foo::bar() in test2.php on line 16 Strict Standards: Non-static method Foo::bar() should not be called statically in test2.php on line 2 Strict Standards: Creating default object from empty value in test2.php on line 3 ----------- Now I add a custom errorhandler: ----------- <?php function myErrorHandler($errno, $errstr, $errfile, $errline) { print "<p>We've got a $errno on line $errline in $errfile!</p>"; } set_error_handler('myErrorHandler'); error_reporting(0); Foo::bar(); $Foo->foo = 0; class Foo { var $baz; function bar() { } } class Foo2 extends Foo { function bar($param1) { } } ?> ----------- The output now is: ----------- Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in test2.php on line 14 Strict Standards: Declaration of Foo2::bar() should be compatible with that of Foo::bar() in test2.php on line 24 ----------- As you can see, two of the E_STRICT errors are still being displayed (this is logical, because they're cast on parse/compile time instead of runtime). The other two though, are not displayed but not passed to my handler either!! If I generate a notice (for example add $bar[a] = 0;) I instantly get an E_NOTICE in my own error handler for the undefined constant: ----------- We've got a 8 on line 13 in test2.php! ----------- So.. Why are the E_STRICTs not passed to my error handler? Bert