Most PHP installations out there are still running PHP 4.x. PHP 5.0 has been out a while, and PHP 5.1.1 has just been released. For those of you who haven't yet upgraded, this month I look at some of the changes you can expect to find in the newer versions of PHP, as well as a preview of what you can look forward to in PHP 6.

Changes in PHP 5.0

As befits an entirely new version number, there are substantial differences between PHP 4 and PHP 5. Most of the hype was around the new object model, which was completely rewritten. The PHP 5 version is much more complete, and performs much better as well. In PHP 4, objects were really just primitive data types, and were referenced by value. In an attempt to retain as much backward compatibility as possible, setting the zend.ze1_compatibility_mode in PHP 5 allows compatibility with the version 4 methods. There are a number of other backward incompatible changes. These include:

Many of these incompatible changes are quite minor, and its likely you'll have to do little, if anything to most of your scripts to get them ready for action on PHP 5. PHP 5 has better ways of doing many things, but if your aim is keeping things going, you shouldn't have too many problems. Other changes in PHP 5 include: For a full list of issues when changing from PHP 4 to PHP 5, see the official documentation on the PHP site.

Changes in PHP 5.1.x

At the time of writing, PHP 5.1.1 has just been released, a quick followup to the controversial 5.1.0. That version caused a mini-riot in the PHP mailing lists. In 5.1.0, certain key changes were hastily included in a late release candidate. Everything was quiet until the storm broke shortly after the final release. However, these changes were reversed in the 5.1.1 to prevent a pear::date conflict. 5.1.0 also ensured it won't go down in the annals with any fond memories by including a couple of severe regressions that were quickly fixed in 5.1.1.

5.1.x has got off to a rocky start, but there are some worthwhile improvements - the inclusion of PDO perhaps being the most far-reaching. See the changelog in the PHP documentation for the full list of PHP 5.1 (and earlier) changes.

Upcoming changes in PHP 6.0

PHP 6.0 looks to be an exciting release. Nothing is absolutely fixed yet, but it looks like it will see the demise of three of my pet peeves: register_globals, magic_quotes_gpc and safe_mode. The first was just a big security hole, the second messed with the data and made changing environments potentially nightmarish, while the third was a misnomer that nobody really understood, and provided a false sense of security. There's also quite a lot of work scheduled to do with Unicode. Here are some of the changes:

There's still much to be determined, namespaces being one of the more important, but as yet there's little agreement. You can read the full minutes from the recent PHP Developer's meeting here where PHP 6 was discussed at length. With PHP 6 still quite a way off, I'm sure there'll be much more wailing and gnashing of teeth before we see the final product, but I'm excited by where it seems to be heading, and the progress that is being made.