|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47981 error handler not called regardless
Submitted: 2009-04-16 08:39 UTC Modified: 2009-04-16 15:55 UTC
From: oliver dot graetz at gmx dot de Assigned: bjori (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2.9 OS: Windows Vista x64 SP1
Private report: No CVE-ID: None
 [2009-04-16 08:39 UTC] oliver dot graetz at gmx dot de
In the documentation of the set_error_handler it says:

It is important to remember that the standard PHP error handler is completely bypassed. error_reporting() settings will have no effect and your error handler will be called regardless

This is wrong! Errors of type E_STRICT will only trigger the custom error handler function if error_reporting explicitly includes them. This clearly means that error_reporting() settings HAVE an effect.

Personally, I think this is an error in PHP and that the behaviour of PHP should be changed to fit the description in the documentation but from the current point this is at least a documentation problem.

Reproduce code:
// --- file 'errorhandler.php' --------------------------------
$errormap = array(
function handleError($errno,$errstr,$errfile,$errline,$errcontext)
  echo "$errno (".$GLOBALS['errormap'][$errno].": $errstr\n";
// --- file 'tester.php' --------------------------------------
include 'errorhandler.php';
$x=5/0; //E_WARNING
echo $not_set; //E_NOTICE
interface a{}
class b implements a { function f($a=1) {}}
class c extends b {function f() {}}

Expected result:
2 (E_WARNING: Division by zero
8 (E_NOTICE: Undefined variable: not_set
2048 (E_STRICT: Declaration of c::f() should be compatible with that of b::f()

Actual result:
2 (E_WARNING: Division by zero
8 (E_NOTICE: Undefined variable: not_set


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-16 13:56 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

 [2009-04-16 15:55 UTC] oliver dot graetz at gmx dot de
If I analyzed the diffs of the last snapshots correctly, the this issue was more esoteric the I imagined, since my test triggered the only use of E_STRICT happening at compile time, that therefore did not use php_error_docref().

Note to self: This problem is very loosely connected to because the E_STRICT is not triggered when not implementing an (empty or non-empty) interface.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 07:05:46 2022 UTC