|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-10-24 05:21 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 20:00:01 2025 UTC |
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);