The Time To Embrace PHP 5.3 Is Here

PHP-logo.pngI am amazed at the number of Drupal modules that do not work under PHP 5.3. Until recently it had been acceptable to write code that didn't work in PHP 5.3. There was a small market share and the initial release of 5.3 had some bugs that made it worthwhile to rely on PHP 5.2. But, with the upcoming release of Drupal 7, which requires at a minimum PHP 5.2, and with PHP 5.3 starting to ship on some of the popular linux versions it's time to make sure Drupal sites run under 5.3 without any problems.

Drupal 7, A Clean Point In Time

Now that modules are being ported to Drupal 7, in anticipation of its upcoming release, we have a perfect opportunity to support PHP 5.3. By support I do not mean rely on PHP 5.3. While it has a fair market share it is still at a point where supporting both PHP 5.2 and 5.3 is beneficial.

This should be easier than when we supported PHP 4.4 through PHP 5.2. The differences between 5.2 and 5.3 are much smaller and both versions are far better than any version of PHP 4.

Differences Between 5.2 and 5.3

In addition to the list of incompatibilities between 5.3 and previous versions there are two items I'd like to highlight.

Call-time pass-by-reference no longer works. That is, when you want a variable passed by reference into a function the & symbol should only be on the variable in the function definition and not when the function is called. Don't use the ereg family of functions. The posix regex functions are now officially deprecated. Instead PCRE should be used for regular expressions.

Multiple Environments On One System

I typically develop under PHP 5.2. I want the ability to develop and test under PHP 5.3 side by side with 5.2. It is possible to setup a second system with the alternate version of PHP but it is more practical, for me, to have it right within my regular development workflow. Luckily there is a lot written about doing just that. Here's a short list.

If you noticed that this fairly OS X centric. Most of the ideas on this, like using FastCGI, will work on other environments (e.g., *nix systems) as well.