Matt brings up some good points. What might be limiting PHP 5 adoption, could just be the lack of interest in developers. The reason or cause for this, in my opinion might be arrogance and also ignorance. Not to put off developers, because I’m damn sure Matt is a better developer than I am.
Up until reading his rant, I’ve lived in a box where everyone I’ve talked to, used and enjoyed PHP 5 and its vast extensions. Developing in PHP 5.0 was uneventfully, but you learn to appreciate PHP 5 with the core inclusion of PDO with PHP 5.1. PHP 5 is not without annoyances. In the core developers attempts to “better” the language, they made changes that broke code that previously worked.
Extensions
With the core inclusion of JSON and improved DateTime extensions in PHP 5.2, I think a lot more people will enjoy working with PHP again. It does bring up some thoughts. The experienced programmers already know how to handle time zones in PHP 4, therefore the ease in 5.2 (and 5.1 with a little bit more code) might not impress them much. For an inexperience programmer, the feature of handling time zones might not be an concern and even then, the ease to an intermediate developer, might be too difficult to an novice.
/* $user_time_zone is based off a database table field
* which stores the information or a cookie which any
* user can change.
* If you are even more brave, you can try Geocoding
* to get the timezone.
*/
date_default_timezone_set($user_time_zone);
Now with any date() or strtotime() call, it will return the time based on the above call. PHP 5.2 makes it even easier to based calls with the DateTime and DateTimeZone objects. Word of warning, they don’t work with 5.1.
The specification of JSON is not difficult, so if you know the format of the string, it is possible to workaround not having the JSON extension. However, I think JSON extension would make any change easier, since you just pass the date to the function. It is probably the easiest of any extension, including probably the Filter extension.
The Filter extension, if security is in the mind of the developer to switch to supporting PHP 5.2.
Who cares about Dedicated?
Dedicated servers don’t matter with the adoption. The discussion should be with shared hosts. The reason is that you have complete control over PHP version, extensions, and well, everything. Those are shared hosts, unless with a host that allows you to install your own version of PHP (which isn’t very many), you have no control besides what they give you in the control panel. You might be able to switch between PHP 4 and PHP 5, but you have no control how PHP is installed, what ini options are set, or what extensions are installed.
That said, I would only count servers that are shared. I would place dedicated along side with developers who choose to support PHP 4, for whatever their reason.
PHP 4 Works
I acknowledge that there are reasons why a developer codes with PHP 4 in mind. WordPress can’t just kick out a large majority of its users by forcing the issue. I do think that many would be willing to upgrade to PHP 5, if they asked.
PHP 4 isn’t so flawed that I would shy away from coding with it. It has most of everything I work with, but I do still find some workarounds time consuming for writing functionality already in PHP 5.
It is just that moving forward, a lot of code dependent on the PHP 4 paradigm isn’t going to work with PHP 6. While I don’t want to write FUD, because most code will work with PHP 6, Register Globals is not.
Register Globals is the Problem
It is more than once that the solution for Register Globals (RG) was to downgrade from PHP 5 or not upgrade to PHP 5. Instead of working on not requiring Register Globals, applications require it. Some are pretty popular or useful enough that many would keep their PHP 4 version. PHP 5 still has Register Globals, unlike PHP 6, but has it disabled. Perhaps it is easier to require PHP 4, than to say how to enable it on PHP 5. Although some shared hosts do enable it, it can’t be counted for every host.
Those developers who don’t want to move forward and instead want to rely on Register Globals, whether because it is easier or because it would take far to long to convert code over from using it. With as many security implications made with Register Globals, I wouldn’t want to use any application that uses it. Recently, I think the choice would be difficult to do without.
Given the choice of paying $80+ on an application that doesn’t require RG or converting a full featured free application that does, which would be worth it? It would take more than a day and it would be unlikely that I’ll have the time to do so.
Something to Love in PHP 5
With as many additions, non-believers will have any something to love about PHP 5. If not PDO, than DOM (which I truly enjoy and use a great deal), or SimpleXML, or XML(Reader|Writer). With as many XML extensions, if you can’t find one easy way, then there would be another not so easy way.
Non-believers should do more research on what PHP 5 can do, because nothing I say here is going to convince anyone otherwise.
Note about Iterators and SPL
Matt remarks that there isn’t enough documentation on Iterators or enough practical use examples. That is incorrect. For every instance you pass an Array to the user for iterating with a foreach loop, you could just pass the object instead. There is enough unofficial documentation on Iterators out there, that I’m sure anyone can find some use for it in WordPress or any application.
Possibly Related Posts: