@madpilot makes

PHP 4 being put out to pasture

Ok, I might be a bit of a Rails zealot now, but I still have a sweet spot for PHP. For many years it was my language of choice, and even today, server hosting or legacy applications still means that I have to throw around the < ?php ?> tag.

I just read on the official PHP website, that as of the end of this year, PHP 4 will no longer be updated, bar crucial security patches. This is a big thing, as many web hosting companies still only support PHP 4 as it isn’t possible to run PHP 5 on the same apache server with out resorting to CGI or proxy work-arounds. This basically means that you have 5 months to make sure that your webiste runs on PHP 5.

The PHP website has a guide to migration, and luckily, most of the time things are fairly smooth. Were you might get in to trouble is the new object model. PHP 5 has a brand new, closer-to-real OOP model that isn’t always completely backwards compatible with it’s older sibling. For example, the __construct() method is called as a constructor, rather than function with the same same as the class as per PHP 4. PHP 5 also supports private, protected and public accessors and methods, as well as native XML and SOAP support.

At this point if, you may want to try running all of your websites as CGI scripts via the PHP5 interpreter to make sure that they can run ok, and if they do, start moving everything over to ensure a smooth transition.

4 comments

  1. I can see a lot of pain. And a lot of clients going well "I'm NOT paying for the upgrade - what do I get nothing, its a techie thing, we don't need it."



    I can see hosting farms still running version 4.3 for years to come.
  2. I have no doubt you are right - I remember coming in to web development just as the PHP 3 to PHP 4 migration was happening. I'm sure you can still find way too many PHP 3 sites kicking around.



    I guess this is a heads up to make sure that sites you can have control over get sorted.
  3. To clarify, if there is no __construct method, PHP5 defers to the old-style constructors.



    Earlier this year I migrated a huge custom PHP application to PHP5 without too many issues. The major issues were with array functions and object cloning .



    The guide to migration is really useful.



    As far as PHP4 is concerned, the big problem is third party applications (e.g. shopping carts). I've already seen some attempts by web hosts to force moves to PHP5, only to have a customer revolt which caused the moves to be abandoned.
  4. Thanks for clearing that up, Chris.

Leave a comment