The Slow Death of PHP 4
Out Of Date Warning
Languages change. Perspectives are different. Ideas move on. This article was published on September 18, 2009 which is more than two years ago. It may be out of date. You should verify that technical information in this article is still current before relying upon it for your own purposes.
Recently, I’ve been getting more and more into community-supplied code, since it’s generally been getting better. Namely, I’ve been exploring the PEAR offerings, and seeing what pieces I can integrate into my personal framework for development. One of these packages is the package called Log, which allows for easy logging of application events.
So imagine my surprise and sadness to learn that the package still supports PHP 4.
The truth is that there are lots and lots of hosts that are still on PHP 4. There are still lots and lots of lines of PHP code that make use of PHP4-level features (see WordPress and Drupal for examples). My complaint is that PHP 4 has been officially unsupported for the last year now, and PHP 5 has been out for over five years. Five years! That’s a long time to wait to take advantage of new features in the language.
Sadly, developing for PHP 4 backwards compatibility is something that companies and individuals are still doing. WordPress released a new Widget API in version 2.8 that relies on the old-style PHP 4 constructor. Apparently, for WordPress and many other developers, wide adoption is more important than language improvements.
In the case of Log, supporting PHP 4 is a reality and a requirement imposed by PEAR. I certainly do not discount the efforts of package maintainers like Jon Parise, Jan Schneider and Chuck Hagenuch, who are bound by PEAR’s rules that prohibit the breaking of backwards compatibility. These individuals are working hard to support a package that is used by hundreds of developers, and is depended on for the proper functioning of 21 individual PEAR packages. I’ve been in the process of working through a PHP 5 version of the Log package, both for my own use and perhaps contribution to the community, because I think that having the ability to use statics, abstracts, interfaces and typehinting are important enough to merit the work.
Still, I look forward to the day when PHP 4 finally does go away forever, leaving us with a much better code base and happier developers.
Write better object
oriented PHP today.
A brand new book on object oriented PHP that will leave you an object oriented master.Learn more about the book »