Tony Marston's Blog About software development, PHP and OOP

Support for PHP4 stops, support for PHP7 starts

by Tony Marston

Release 2.00.0 of the Radicore framework officially ends support for PHP4 and starts support for PHP7. For many years I have been able to support both PHP4 and PHP5 with the same code base which meant that users could switch from one to the other at any time without having to change a single line of code. By deliberately ignoring any of the shiny new features which have been added to PHP5 (unless I have found a genuine need for the functionality which they offer, which has been very rare) I have been able to move through all the versions of PHP5 without having to deal with any BC breaks. The only exception to this was the replacement of the POSIX regular expression functions with the PCRE functions following their deprecation in version 5.3.0.

While it was possible to support both PHP4 and PHP5 with the same codebase, it is not possible to add support for PHP7 because of one change - class constructors:

In PHP4 a class constructor was identified as a method with the same name as the class.

In PHP5 it became possible to use the magic name "__construct", but PHP4 constructors were still allowed.

In PHP 7.0.0 all PHP4 constructors are marked as deprecated, and from 7.1.0 onwards they will be completely rejected.

In order to make my codebase run in PHP7 without incident I have therefore had to update all of my classes to replace the PHP4-style constructors with the PHP5 version. While this means that the same code can now run in either PHP5 or PHP7, it will no longer run in PHP4.

Oh dear, what a pity, how sad. Let us bow our heads and observe a minute's silence for the passing of PHP4.

Please note that this is the ONLY change I have had to make to my codebase to make the jump from PHP5 to PHP7. Other developers seem to be having difficulties, even with moving from 5.3.0 to 5.4.0, 5.5.0 and 5.6.0, but that can only be down to the poor quality of the code which they write. As far as I am concerened if you have to keep rewriting your code with each new release of PHP then you are doing something wrong.

Please enable JavaScript to view the comments powered by Disqus.