PHP5: The Times Are A Changin’ September 27th, 2008

08/08/2008 was certainly not another Y2K-like event, but it is the End-of-Life (EOL) date for PHP4. For those of you wondering exactly what EOL means, it is the day when support ends for a product. This alone should propel any pragmatic programmer (redundant, I know) to move into the brave new world of PHP5. The latest release for PHP5 is version 5.2.6, released back in May. While PHP5 is designed to be backwards-compatible with PHP4, it does cause some minor issues with scripts written for PHP4. This is because PHP continues to trend away from the use of wicked little things such as register_globals – which it will phase out entirely with the introduction of PHP6, already in development (and fairly close to going public, I might add).

Are you convinced that the time has arrived to move from PHP4 to PHP5, yet? If not:

Brief Overview of Changes From PHP4 to PHP5

  • New in PHP5, all objects are now passed by reference. You absolutely must clone an object now. Please also note that you can cease using the reference operator (&) to get around that pesky pass-by-value functionality.
  • PHP now has three levels of visibility for class methods and properties. Public is readable by everyone, Protected makes members only accessible by parent and sub classes, and Private makes members only available to the class itself.
  • The abstract class can now be declared – this new class is purely used to define a model where other classes extend.
  • Class Constants and Static Method/Properties are now available.
  • Unified Constructors and Destructors (__construct() and __destruct(), respectively) now allow for proper construction and destruction.
  • Common APIs now can use Interfaces.
  • “Magic Methods” now introduce some handy features – probably best just to look at the list.
  • You can now employ the final keyword to block a child from overwriting a method.
  • The __autoload function now allows for automatic loading of object files when a class has yet to be encountered.
  • New SPL functions.
  • Type-hinting which means that you can control what variables are passed to functions or class methods, but only currently in classes or arrays.
  • PHP introduces exceptions (finally)!
  • The E_Strict Error Level will now let you know when you used depreciated code.

The above is a very basic and quick overview, I always recommend going to the manual for more information! On top of all of that, PHP5 brings many new functions to the table. On top of this are the new extensions: SimpleXML, DOM, XSL, PDO, Hash.

Again, I recommend checking up on the backwards compatibility information, as this will help you identify where you are probably going to have problems. Some major catches include array_merge(), which will only allow arrays now, and get_() now returns names as defined, making get_class() case sensitive.

The change from PHP4 to PHP5 is not all that painful. You can arm yourself with the knowledge necessary to make it virtually painless. PHP is just like the internet. It is constantly evolving and you will be left in the dust. With PHP6 already on the horizon, do you really want to be using an unsupported and exploitable language in this day and age?

Make the switch and enjoy the benefits of PHP5!

4 Responses

  1. jj says:

    > Make the switch and enjoy the benefits of PHP5!

    That’s what I would have told to Idologic 4 years ago 😉 I must remind you that, after PHP5 came out, it took you quite a long time to add it to the shared servers, and when you did, the extension had to be .php5. Of course there were issues with cPanel and all that and you did the best you could, and I understand that. But now you’re asking to move to PHP5 as if there had never been any limitations on the server side to actually use PHP5 😉 I would have moved to PHP5 four years ago if I had been able to! 😉

    It hasn’t been easy for any of us, anyway 🙂

  2. webmaster says:

    Thank you for your comment; note PHP5 has been available at least since October 2005 on most servers You do not need to use a .php5 extension if you drop in a .htaccess. (

    Unfortunately at the time many scripts didn’t work on php5.

    Either way, on to php6 now! 😀

  3. jj says:

    My bad. Then I completely misunderstood the problems with PHP5… 🙁

    Anyway… PHP6… oh my… so when is is supposed to come out? are you already planning installing it? 😉

  4. webmaster says:

    Nah, I was just joking about php 6; the next thing on the list is the mysql 5 cluster, which is ready, but now I just have to figure out how to get cPanel to play nice with it.

Leave a Reply

Your email address will not be published. Required fields are marked *