note 124120 added to function.exit

From: Date: Fri, 16 Aug 2019 13:04:46 +0000
Subject: note 124120 added to function.exit
Groups: php.notes 
Request: Send a blank email to php-notes+get-211893@lists.php.net to get a copy of this message
Might be evident for some but I think the documentation is missing how exit behaves when placed in a try-catch. It only exits the current try and continue after the catch! Consider the following code: foreach (['trois','petits','chats'] as $x){ try{ echo $x.' [before]'; exit; echo ' [after]'; }catch(Exception $ex){} echo ' [out]\n'; } //in PHP 7.2 I have the following output trois [before] [out] petits [before] [out] chats [before] [out] ---- Server IP: 208.43.231.9 Probable Submitter: 82.199.157.54 (proxied: 206.167.168.129) ---- Manual Page -- http://php.net/manual/en/function.exit.php Edit -- https://master.php.net/note/edit/124120 Del: integrated -- https://master.php.net/note/delete/124120/integrated Del: useless -- https://master.php.net/note/delete/124120/useless Del: bad code -- https://master.php.net/note/delete/124120/bad+code Del: spam -- https://master.php.net/note/delete/124120/spam Del: non-english -- https://master.php.net/note/delete/124120/non-english Del: in docs -- https://master.php.net/note/delete/124120/in+docs Del: other reasons-- https://master.php.net/note/delete/124120 Reject -- https://master.php.net/note/reject/124120 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#211893) next »