News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Joshua Thijssen:
PHP5.5 Try/Catch/Finally
February 12, 2013 @ 10:03:23

Joshua Thjissen has a new post to his site today about a feature that's been introduced in the upcoming PHP 5.5 release of the language - the addition of "finally" to try/catch exception handling. He gets into it a bit more technically than just the "introductory" level, discussing parent/child exception handling and using returns.

Exception handling is available in PHP since version 5. It allows you to have a more fine-grained control over code when things go wrong ie, when exceptions occur. But since PHP 5.5, exception handling has finally evolved into what it should have been from the beginning: the "finally" part has been implemented.

He includes a basic example showing how a certain part is always executed, regardless of if the exception is thrown or not. He also shows how a "chained catch" would work to catch multiple kinds of exceptions and when the "finally" is run as it relates to the "trickle down" handling of exceptions. He then gets a little more complex and introduces "return" into the mix. Of special note, even if you return, the "finally" will still get called.

0 comments voice your opinion now!
try catch finally handling exception parent return


blog comments powered by Disqus

Similar Posts

DevShed: PHP Functions

PHPMaster.com: Patterns for Flexible View Handling, Part 2 - Using Decorators

DevShed: Emulating a Basic Web Server with Sockets in PHP

Chris Hartjes' Blog: The Story and Rebirth Of Zend_Service_Audioscrobbler, Part 2

Jani Hartikainen's Blog: Understanding Doctrine's NestedSet feature


Community Events





Don't see your event here?
Let us know!


composer interview configure version community list framework conference introduction laravel unittest series voicesoftheelephpant install symfony api extension opinion podcast release

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework