|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-14 08:21 UTC] lsole at maresme dot net
[2004-03-14 13:09 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 16 22:00:01 2025 UTC |
Description: ------------ @unserialize() throws E_NOTICE with custom handler Reproduce code: --------------- <?php function myErrorHandler($errno, $errmsg, $filename, $linenum) { if ($errno == 0) return; $error_type = array(0 => 'No Error', 8 => 'Notice'); // just the ones we need... echo '<b>' . $error_type[$errno] . '</b>: ' . $errmsg . ' in <b>' . $filename . '</b> on line <b>' . $linenum . '</b><br>' . chr(10); } $a = 'abc123'; error_reporting(E_ALL); $b = unserialize($a); // throws error because $a is not unserializable if ($b === false) {echo 'failed!<br>';} else {echo $b . '<br>';} $b = @unserialize($a); // @ suppresses error if ($b === false) {echo 'failed!<br>';} else {echo $b . '<br>';} set_error_handler('myErrorHandler'); $b = unserialize($a); // throws error because $a is not unserializable if ($b === false) {echo 'failed!<br>';} else {echo $b . '<br>';} $b = @unserialize($a); // should throw nothing but throws Notice! if ($b === false) {echo 'failed!<br>';} else {echo $b . '<br>';} ?> Expected result: ---------------- E_NOTICE errors should not happen when prepending @: the custom handler should receive $errno = 0 Actual result: -------------- E_NOTICE error