note 112487 added to language.exceptions
| From: | Gordon | Date: | Fri, 21 Jun 2013 07:37:08 +0000 |
| Subject: | note 112487 added to language.exceptions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195312@lists.php.net to get a copy of this message | ||
One thing the documentation doesn't mention is that, just like Java, you can have a finally
block after a try block, without any catch block at all.
This is very useful, because you can put all your cleanup code in the finally block and it's
executed whether there's an exception thrown or not, but if an exception is thrown it can be
caught some place else with the knowledge that the failed operation was already properly cleaned up
after.
<?php
try {
throw new Exception ('I'm not caught in this try/ block!');
} finally {
echo 'This is where my cleanup logic goes';
}
http://stackoverflow.com/questions/17208838/php-5-5-and-try-finally
----
Server IP: 94.76.225.145
Probable Submitter: 82.31.125.253
----
Manual Page -- http://php.net/manual/en/language.exceptions.php
Edit -- https://master.php.net/note/edit/112487
Del: integrated -- https://master.php.net/note/delete/112487/integrated
Del: useless -- https://master.php.net/note/delete/112487/useless
Del: bad code -- https://master.php.net/note/delete/112487/bad+code
Del: spam -- https://master.php.net/note/delete/112487/spam
Del: non-english -- https://master.php.net/note/delete/112487/non-english
Del: in docs -- https://master.php.net/note/delete/112487/in+docs
Del: other reasons-- https://master.php.net/note/delete/112487
Reject -- https://master.php.net/note/reject/112487
Search -- https://master.php.net/manage/user-notes.php