php[architect] logo

Want to check out an issue? Sign up to receive a special offer.

PHP 5.3 is Coming: Are You Ready?

Posted by on June 22, 2009

According to a recent e-mail sent by Release Manager Lukas Smith to the developer mailing list, the PHP team is in the final stages of preparing PHP 5.3 for a public release. With 5.3 just around the corner, the worst mistake that any PHP developer can do is to think of it as just another point release—something you go ahead and install on your server without giving it a second thought (after you’ve run all your tests, of course).

More Than a Pretty Face

There’s a lot more about PHP 5.3 than first meets the eye. Despite the fact that it is only a point release, it introduces a few new powerful features—some originally slated for release in PHP 6.0—that you can start taking advantage of today to improve certain aspects of your website.

One of these—perhaps the one that has been coming the longest—is

namespaces, which have been in the works for years and have been the source of much discussion (some of it quite heated) on the internals list.

Like in most other languages, Namespaces allow you better encapsulate your code, while at the same time limiting the chances of colliding against duplicate symbols defined by someone else—for example, the developers of an external library or framework that you use in your projects.

Along with namespaces, PHP 5.3 also introduces the use keyword, which allow you to import one or more namespaces in your project.

Static Member Handling

A lot of work has gone into improving the handling of static class members in 5.3—for example, you can now use the __callstatic() magic method to handle dynamic static method calls, while a new feature called late static binding improve scope resolution within the static methods of parents of a subclass.

Lambdas and Closures

For the first time, PHP 5.3 supports the concept of closures and lambda functions. This means that functions are now treated as a special datatype that can be passed as a parameter to a function call.

Much like you would in Javascript or ActionScript 3, you can create anonymous functions (lambdas) and use them as closure by giving them access to data that would normally be out of scope to them.

…and More!

The Standard PHP Library is also getting a facelift of sorts, with a number of new classes, functions and iterators added. Similarly, PHP is getting a new garbage collector, an improved HEREDOC syntax, a GOTO operator, a large number of bug fixes and an overall speed boost of around 25%.

Here are some more resources to give you a jumpstart on your PHP 5.3 reading:


Marco is the keeper of keys and Chief Garbage Collector at Blue Parabola. He can be found on Twitter as @mtabini.
Tags:
 

Leave a comment

Use the form below to leave a comment: