note 80883 deleted from function.set-error-handler by cmb

From: Date: Sun, 13 Oct 2019 07:29:41 +0000
Subject: note 80883 deleted from function.set-error-handler by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212587@lists.php.net to get a copy of this message
Note Submitter: m0sh3 at hotmail dot com ---- Looks like there's no way to distinguish between catched exceptions thrown by internal classes and real warnings in custom error handlers: <?php function handleError($n, $m, $f, $l) { //no difference between excpetions and E_WARNING echo "user error handler: e_warning=".E_WARNING." num=".$n." msg=".$m." line=".$l."\n"; return true; //change to return false to make the "catch" block execute; } set_error_handler('handleError'); //turn off to make try/catch work normally //uncomment this for a regular warning timezone_open(1202229163); //comment this whole try/catch out to see new DateTimeZone outside of a try / catch //behavior is the same if you have set a custom error handler //echo new DateTimeZone(1202229163); //* try { $z = new DateTimeZone(1202229163); } catch (Exception $e) { echo "caught"; } // */ ?>

« previous php.notes (#212587) next »