How to upgrade your version of PHP
If you’re running websites with an out-of-date version of PHP, we recommend that you upgrade to a newer version. A newer version is more likely to be protected from security vulnerabilities and attacks because the PHP community releases regular security patches and updates to known bugs. As well as the security updates, PHP 7 comes with new features and increased performance. For example, applications like WordPress can run up to twice as fast with PHP 7 when compared with PHP 5.4. Find out more about the benefits of PHP 7.
Versions that are now unsupported from the PHP community are PHP 5.4, 5.2, and everything before them.
Before the upgrade…
Changes made in the new version can affect code written in an old version. A site written in PHP 5.4 might break when upgraded to PHP 5.6 because of the difference between the versions. There are functions that work differently in the two versions, there are new functions, and functions that have been removed. This could cause your website to break after the upgrade.
As well as functions there are a range of backwards incompatible changes between a new version and an earlier version which could cause a breakage. These could include changes to parameters, scripts, methods and directives.
PHP 7 helps to tighten up a lot of code, making it easier and more secure to code efficiently. This means that some redundant functions were removed. Features like the new null coalescing operator were added to make code easier to manage and more robust.
With PHP 7 ext/mysql functions were removed, which changed the way MySQL API works, they also removed support for ASP and script tags <%, <%= and <script language=”php”>. Also, it is no longer possible to have two parameters with the same name within a function, and the JSON extension was replaced with JSOND which requires that numbers within JSON must not end in a decimal point.
These minor changes between versions could cause disruptions to a website, so it’s recommended that you look at what’s changed before you upgrade your version, to ensure that your website will still work on a newer version of PHP. We have produced guides that will help with the migration from PHP 5.2 to 5.6, and from PHP 5.4 to 5.6, as well as a guide to help with the upgrade to PHP 7.
If you are a Fasthosts web hosting customer you can upgrade your version of PHP by following this guide that we have created.
We recently wrote about how PHP powers WordPress, and how important it is to keep your software up-to-date. For help updating WordPress, read this article on our support site, and watch this video on our YouTube channel.