|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-05-30 22:12 UTC] requinix@php.net
-Summary: restore_exception_handler in finally block runs
before catch
+Summary: restore_exception_handler in finally block runs
before global exception handler
-Status: Open
+Status: Not a bug
[2016-05-30 22:12 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 24 10:00:02 2025 UTC |
Description: ------------ When restore_exception_handler is called in a finally block, the *restored* exception handler handles the exception. I would expect the exception to be fully resolved before restore_exception_handler takes effect. The PHP documentation states "Code within the finally block will always be executed after the try and catch blocks, regardless of whether an exception has been thrown, and before normal execution resumes." Test script: --------------- <?php function handler1($e) { echo "\nhandler1"; } function handler2($e) { echo "\nhandler2"; } set_exception_handler('handler1'); set_exception_handler('handler2'); try { throw new Exception(); // 'handler1' is displayed. Expected: 'handler2' } finally { restore_exception_handler(); }