|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-11-13 10:35 UTC] ukrtelecom at gmail dot com
Description: ------------ set_error_handler returns the previously defined error handler for any mask. It must be related to https://bugs.php.net/bug.php?id=63206 Test script: --------------- <?php $cb = function ($errno, $errstr, $errfile, $errline, $errcontext){return false;}; var_dump(set_error_handler($cb, E_NOTICE)); var_dump(set_error_handler($cb, E_WARNING)); Expected result: ---------------- NULL NULL Actual result: -------------- NULL object(Closure)#1 (1) { ["parameter"]=> array(5) { ["$errno"]=> string(10) "<required>" ["$errstr"]=> string(10) "<required>" ["$errfile"]=> string(10) "<required>" ["$errline"]=> string(10) "<required>" ["$errcontext"]=> string(10) "<required>" } } PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 09:00:02 2026 UTC |
Thanks Damian, I see what you mean, and it turned to even worse behaviour: in my scenario the handler I carefully defined for E_NOTICE errors will never be called. set_error_handler(function(){echo 1;}, E_NOTICE); set_error_handler(function(){echo 2;}, E_WARNING); echo $someUndefinedVar; results with ugly "Notice: Undefined variable: someUndefinedVar" instead of beautiful "1". I respect that my expectation to fire my handlers are too high, and it is not a bug. Could we classify it as a feature request then? You see, having a returned value from set_error_handler() I have no information about what errors it was handling before, which make it useless. What realistically you can do with previous handler with current implementation?