Quantcast
Channel: PHP vs .Net » PHP
Viewing all articles
Browse latest Browse all 10

PHP 5.3 – Namespaces and Late Static Binding

$
0
0

Work on the Mono machine continues. For reasons as yet undisclosed, I'm rebuilding the Mono test box from scratch. I'm not expecting this to resolve the previous issues I experienced while benchmarking Mono, but it is allowing me to tie up some loose ends. More on that soon.

In the meantime, I noticed a new article over at Sitepoint about the upcoming PHP 5.3 release, slated for later this year. Apparently some new features which were originally scheduled for PHP 6 are now included in 5.3, including Late Static Binding, and Namespaces!

While I can't get too excited about Namespaces, I know there are people out there that will love the fact that they will finally be arriving to PHP-land. By its very nature a lot of PHP projects are small, and you can usually get along fine without Namespaces on a small project. But with larger PHP sites and applications like Facebook becoming more commonplace, Namespaces are bound to come in exceedingly useful for some people.

On a more personal-project level, I find Late Static Binding to be much more exciting. The examples given in the Sitepoint article are very thorough so I won't reprint them here, but the quick summary is that if you have a function in a Parent class that uses the self:: operator, you can't call that function from the perspective of a Child class, as self:: always references the class it is in (ie. the Parent). Late Static Binding will give PHP developers a new reference called static:: which changes that; it will resolve to the static class at runtime (ie. the Child). This will allow for a much more intuitive extensions of parent classes in object-oriented PHP!

Good stuff, you should check it out.


Viewing all articles
Browse latest Browse all 10

Trending Articles