News Feed
Sections




News Archive
feed this:

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

PHPMaster.com:
Lesser-Known "Features" of PHP's OO Model
July 22, 2013 @ 12:21:22

On PHPMaster.com there's a new tutorial from Lorna Mitchell about some of the lesser known OOP features that are built in to the PHP language. She talks about things like interface inheritance, private properties and autoloading and type hints.

The vast majority of today's applications written in PHP are object-oriented, and in general the core OOP concepts are pretty well understood by PHP developers. This article pushes the boundary of your understanding and shows you some tricks, or potential pitfalls depending on your perspective, of OOP in PHP.

Besides the ones mentioned above, she also looks at abstract classes and their use as well as the use of "finally" to handle the cleanup after exceptions.

0 comments voice your opinion now!
features oop model language private inheritance typehint finally

Link: http://phpmaster.com/lesser-known-features-of-phps-oo-model

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


Aaron McGowan:
Finally generators exist as of PHP 5.5
January 17, 2013 @ 12:37:27

In this new post to his site Aaron McGowan talks about new features of the upcoming PHP 5.5 release - the "finally" keyword and generators.

PHP 5.5 has recently been released as an ALPHA release, meaning there are still bugs, code is being tested and features being added. With the 5.5 release, many of us PHP developers have a few wonderful new features that we should be taking advantage of almost immediately.

He gives brief introductions to these two new features, including some code examples (but getting a bit more into the generators side of things). You can find out more about these two features and how to implement them when PHP 5.5 comes around from the PHP sitel: generators and finally (actually from the PHP wiki).

0 comments voice your opinion now!
finally generators introduction version update


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



Community Events





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


interview tool laravel release install update security podcast package series composer version library framework community symfony introduction language opinion voicesoftheelephpant

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