Codex tools: Log in
This article is to answer questions about making the move from PHP 4.x to PHP 5.x on your web hosting platform.
To identify the version of PHP your web server is using, download the WordPress Health Check plugin. When you activate the plugin, it will tell you if you are ready for WordPress 3.2. If it is not, contact your web hosting provider and ask them to provide support for PHP 5. Tips are available below.
WordPress developers and Theme and Plugin authors use the current PHP version 5.2 for some time, staying current with improvements in coding technology. Current and updated versions should be compliant and you should not run into any problems when you upgrade your hosting to a recent PHP version like PHP 5.2.x or 5.3.x.
Infact WordPress runs better on PHP 5 than it does on PHP 4. PHP 4 is outdated and WordPress is not much tested to run on it any longer (not as much as PHP 5 by far at least). And for many plugins and themes this is the same, PHP 5.2 is supported right now on most hosts.
Some bugs do only exist when you run WordPress on PHP 4 but they do not exist when you run it on PHP 5. In these cases not PHP 5 but PHP 4 is the problem.
Some WordPress Plugin and Theme authors are working on versions that are only compatible with PHP 5 and it's improved features and capabilities. So these do not even work with PHP 4 or older PHP 5 versions.
However, older Themes and Plugins may have PHP code that eventually might not work with every PHP 5 version. Check with the Theme and Plugin authors for the specific requirements of the plugins you're using. PHP 4 is officially end of live since August 2008 (that means no security patches since longer than a year ago). If your plugin has not been updated since years, please look for updated versions, or consider changing to an alternative option.
Switching from PHP 4 to PHP 5.2 is known to cause an issue wherein gibberish appears above the Wordpress blog header related to "open_basedir restriction." It usually runs like this:
Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/MY_ACCOUNT:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php: /usr/local/php4/lib/php:/tmp) in /home/MY_ACCOUNT/wp-includes/functions.php on line 1942
This can easily be corrected by editing the MySQL table. Search for wp_options and find "option_name = ‘upload_path’" and shorten the value in the column. For example, if the value in it is ‘/home/MY_ACCOUNT/wp-content/uploads,' change it to ‘wp-content/uploads’. More information can be found here
This list is intended to show examples of how to swap to PHP5 on various hosts. This is not a complete, nor official list. Please check with your web host for specific and updated information.
AddType x-mapp-php5 .php AddHandler x-mapp-php5 .php
SetEnv PHP_VER 5
In August 2008 PHP 4 became an end-of-life product. This meant that no further effort would be expended in fixing bugs, improving, or patching security holes found in PHP version 4. Development effort moved to PHP 5.
Since then, web hosts have gradually been introducing PHP 5 based offerings into their portfolios. Most decent web hosting providers will now allow PHP 5 hosting - though for some it may not be the default.
Compared to PHP 4, PHP 5 is faster, easier for developers to maintain and code for, and integrates better into web services. Perhaps most importantly, it is also a current, supported, product.
Currently WordPress works on both PHP 4 and PHP 5 based platforms. The historic viewpoint has been that WordPress would continue to have a PHP 4 minimum requirement until the user base reached a tipping point in PHP 5 adoption.
Clearly the WordPress developers cannot continue to code for PHP 4 indefinitely. Current feeling is that many PHP 5 only features may be introduced in WordPress 3.0. Some existing features, such as advanced timezone support, are already in WordPress and rely on capabilities present only in PHP 5.
The change is more likely to be a drift away from PHP 4 than a sudden detour. For example, more people have success with the Automatic Upgrade functionality when they are running on a PHP5 host.
As of September 2011, attempting to upgrade to Wordpress 3.2.1 on PHP 4 will result in your blog becoming unusable. A single line of text will display that will read:
Your server is running PHP version 4.4.9-nfsn1 but WordPress 3.2.1 requires at least 5.2.4.
If you are running PHP 4, it is highly recommended you avoid upgrading to Wordpress 3.2.1, and first focus on upgrading PHP.