note 117146 added to function.exit
| From: | theonenkl at gmail dot com | Date: | Tue, 21 Apr 2015 15:33:39 +0000 |
| Subject: | note 117146 added to function.exit | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202315@lists.php.net to get a copy of this message | ||
A side-note for the use of exit with finally: if you exit somewhere in a try block, the finally
won't be executed. Could not sound obvious: for instance in Java you never issue an exit, at
least a return in your controller; in PHP instead you could find yourself exiting from a controller
method (e.g. in case you issue a redirect).
Here follows the POC:
<?php
echo "testing finally wit exit\n";
try {
echo "In try, exiting\n";
exit;
} catch(Exception $e) {
echo "catched\n";
} finally {
echo "in finally\n";
}
echo "In the end\n";
?>
This will print:
testing finally wit exit
In try, exiting
----
Server IP: 72.52.91.14
Probable Submitter: 149.62.65.94
----
Manual Page -- http://php.net/manual/en/function.exit.php
Edit -- https://master.php.net/note/edit/117146
Del: integrated -- https://master.php.net/note/delete/117146/integrated
Del: useless -- https://master.php.net/note/delete/117146/useless
Del: bad code -- https://master.php.net/note/delete/117146/bad+code
Del: spam -- https://master.php.net/note/delete/117146/spam
Del: non-english -- https://master.php.net/note/delete/117146/non-english
Del: in docs -- https://master.php.net/note/delete/117146/in+docs
Del: other reasons-- https://master.php.net/note/delete/117146
Reject -- https://master.php.net/note/reject/117146
Search -- https://master.php.net/manage/user-notes.php