News Feed
Sections




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

Sherif Ramadan:
Finally Getting finally In PHP?
August 09, 2012 @ 10:53:55

In this recent post to his site Sherif Ramadan looks at a proposal that's currently under view (RFC) to add the "finally" keyword to PHP.

It's quite possible that PHP may finally be getting the addition of the finally block in its try/catch block. [...] It also solves a simple, but overlooked problem for the developer. With finally we offer the user-space code a chance to do any clean up work that may be necessary after a try block has terminated execution and with clear semantics.

He includes a use case for this feature - an example showing exception handling on multiple levels and writing to log files when the cleanup of the exception is finished (without the potential for another method to trigger the exception itself). "Finally" allows you to take this logic out of the exception handling and put it at the end, removing the possibility of it triggering an exception for the wrong reason. There's a few other examples showing some other quirks with its usage - like calling die will not make it end up in the "finally".

0 comments voice your opinion now!
finally rfc keyword exception handling proposal


blog comments powered by Disqus

Similar Posts

Sandro Groganz\'s Blog: Submit your Proposals for eZ publish Conference

David Sklar's Blog: Runkit, "static", and inheritance

Stubbles Blog: Exception is an Inheritance Nazi

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

Zend Developer Zone: The ZendCon Sessions Episode 24: Elegant Ways of Handling PHP Errors and Except


Community Events





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


threedevsandamaybe code framework project api library community list language release developer wordpress laravel series configure podcast introduction application bugfix interview

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