#46374 [Opn]: Error-control operator does not suppress "undefined index" in set_error_handler
| From: | kalle@php.net | Date: | Sat, 25 Oct 2008 12:29:20 +0000 |
| Subject: | #46374 [Opn]: Error-control operator does not suppress "undefined index" in set_error_handler | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1238@lists.php.net to get a copy of this message | ||
ID: 46374
Updated by: kalle@php.net
Reported By: phpbugs at sevenlight dot com
Status: Open
Bug Type: Documentation problem
Operating System: *
PHP Version: 5.2.6
New Comment:
Correct me if I'm wrong, but this doesn't looks like an documentation
issue. Its probably your error reporting thats set to E_ALL, and not
E_ALL & ~E_NOTICE so notices will be generated.
You can set the optional second parameter on set_error_handler to
ignore notices, eg.:
set_error_reporting('ErrorHandler', E_ALL & ~E_NOTICE);
Previous Comments:
------------------------------------------------------------------------
[2008-10-24 05:21:39] phpbugs at sevenlight dot com
Description:
------------
A set_error_handler() callback is receiving an error code of 8
(E_NOTICE) for an undefined index, even though it has been suppressed by
the @ operator. As per the documentation, the value of the error should
be 0.
Tested on 5.2 and 5.3.
This is potentially just a documentation problem?
I find that the error code could be useful even if it has been
suppressed, therefore suggesting that an extra variable being passed to
the callback notifying it whether or not the @ operator was used or not
would be more useful.
Reproduce code:
---------------
<?php
function ErrorHandler($iErr, $sError)
{
if ($iErr) {
die('This should not happen (' . $iErr . '). Error should have
been suppressed: ' . $sError);
} else {
die('Error suppressed.');
}
}
set_error_handler('ErrorHandler');
$a = array();
echo @$a[ 'suppress-me' ];
?>
Expected result:
----------------
Error suppressed.
Actual result:
--------------
This should not happen (8). Error should have been suppressed:
Undefined index: suppress-me
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46374&edit=1