|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-11 08:11 UTC] pollita@php.net
[2005-02-11 15:54 UTC] joh at deworks dot net
[2005-02-11 21:52 UTC] pollita@php.net
[2005-02-12 00:38 UTC] joh at deworks dot net
[2005-02-14 10:02 UTC] vrana@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 08:00:01 2025 UTC |
Description: ------------ E_STRICT errors are passed to a custom error handler when the errors appear in an included file. The documentation for set_error_handler() clearly states that "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, and E_STRICT". This is true, if the error occurs in the same file as the error handler, but when a file which triggers an E_STRICT warning is included, PHP passes the error to the custom error handler. As this only happens when including an erroneous file, I'm reporting this bug as a Scripting Engine problem, and not a Documentation problem. I've tested this on the latest 5.1.0 (200502101130) development snapshot. Reproduce code: --------------- errorhandler.php: <?php function errorHandler($severity, $message, $file = null, $line = null, $context = array()) { static $severityMap = array( E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_PARSE', E_NOTICE => 'E_NOTICE', E_CORE_ERROR => 'E_CORE_ERROR', E_CORE_WARNING => 'E_CORE_WARNING', E_COMPILE_ERROR => 'E_COMPILE_ERROR', E_COMPILE_WARNING => 'E_COMPILE_WARNING', E_USER_ERROR => 'E_USER_ERROR', E_USER_WARNING => 'E_USER_WARNING', E_USER_NOTICE => 'E_USER_NOTICE', E_STRICT => 'E_STRICT' ); echo '<strong>' . __METHOD__ . ': PHP Error with severity ' . $severityMap[$severity] . '(' . $severity . ') raised: ' . $message . "</strong><br />"; } set_error_handler('errorHandler'); include 'strict.php'; ?> strict.php: <?php class Foo { public function __construct() { } public function Foo() { } } ?> Expected result: ---------------- Strict Standards: Redefining already defined constructor for class Foo in strict.php on line 4 Actual result: -------------- errorHandler: PHP Error with severity E_STRICT(2048) raised: Redefining already defined constructor for class Foo