nav-left cat-right
cat-right

PHP 5.3 – Namespaces and Late Static Binding

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.

  • Digg
  • del.icio.us
  • DotNetKicks
  • Slashdot
  • StumbleUpon

2 Responses to “PHP 5.3 – Namespaces and Late Static Binding”

  1. morgan says:

    Seems like PHP is getting more and more like ASP.Net all the time. :p

  2. blake says:

    Don't make me come over there and install IIS. I promise you it won't be pretty!

Leave a Reply