You can safely say that PHP has helped shape the World Wide Web as we know it.
It’s a server-side scripting language designed primarily for web development. Thanks to its existence, websites have grown from the static collections of HTML files and images we browsed in the early 2000s to today’s highly complex and functional web applications.
It’s also the primary programming language used in WordPress, so it’s directly responsible for the operation of more than 40% of the world’s active websites.
The owners of these websites should remember that using the wrong PHP version could severely affect the user experience. They’ll be interested in learning how to update it.
Let’s not keep them waiting.
PHP and WordPress: How Do They Work?
When Rasmus Lerdorf laid PHP’s foundations back in 1994, he called the collection of scripts he had created Personal Home Page, which was apt considering he used them to manage his own website. A year later, he released PHP as an open-sourced project, and a team of contributors started developing the language.
By 2003, PHP had established itself as a fast and reliable server-side language for web development. Matt Mullenweg and Mike Little knew this when they started working on WordPress.
WordPress wouldn’t work without PHP. Unlike a static website, it utilizes a database model and is dependent on a number of server-side scripts.
You and your website visitors generate data in the form of anything from blog posts through login credentials to comments. The code in your site’s .php files tells WordPress how to store all that data in the database. When a specific URL is requested, it also shows the CMS how to use MySQL user authentication to retrieve and compile the data into HTML web pages the browser can read.
Obviously, this is a very simplified explanation of how WordPress functions. The CMS has been around for over two decades, and the innovations implemented throughout these years have expanded WP’s functionality immensely.
Which PHP Versions Does My WordPress Website Support?
The version of PHP you need depends largely on the version of the WordPress core you’re using. Let’s look at all major WordPress releases and the PHP versions they support.
WordPress 1.x
When WordPress was officially launched, most servers and web browsers supported PHP 4.1, which was the minimum requirement for the first WP sites.
At the time, WordPress was still primarily a blogging platform, so the stability and performance delivered by PHP 4.1 were more than good enough.
WordPress 2.x
When WordPress 2.0 came out in 2005, its requirements for the minimum PHP version remained unchanged – PHP 4.1. However, the developers announced from the very start that WP websites would work better on PHP 4.3 or newer.
By WordPress 2.5, PHP 4.3 was the minimum requirement, and PHP 5.0+ was recommended for the best possible performance.
WordPress 3.x
WordPress 3.0 was a significant milestone in the platform’s shift from a blogging application to an all-round CMS. This meant it initially needed at least PHP 5.2.4 to run, though 5.3 had been released at the time.
As WP’s developers added more options to WordPress 3.x versions, they started recommending the use of PHP 5.4 or newer.
WordPress 4.x
All WordPress 4.x releases supported PHP 5.2.4. The idea was to guarantee backward compatibility with older PHP versions and encourage users to update their CMS cores.
However, after WordPress 4.7 came out, the developers recommended upgrading to PHP 5.6 or newer for better performance and security.
WordPress 5.x
The Gutenberg block editor was introduced with WordPress 5.0, and the minimum PHP version requirement was upped to 5.6.20. At the time, PHP 7.0 had been recently introduced and was soon the recommended option for WordPress websites.
PHP 8.0 also came out not long after that, but adapting WordPress to work with it proved difficult, so the recommended versions for the later 5.x releases remained PHP 7.3 and 7.4.
WordPress 6.x
The latest WordPress series still supports PHP 5.6.20, but its use is strongly discouraged. The development team has made the necessary changes to make the CMS work with PHP’s latest versions, so if you want the best performance and security, think about deploying it on a hosting account running at least PHP 8.0 or PHP 8.1.
Here’s a summary of what PHP versions you should use depending on the WP release powering your website:
WordPress version | Minimum PHP version | Recommended PHP version |
---|---|---|
WordPress 1.x | PHP 4.1 | PHP 4.1+ |
WordPress 2.x | PHP 4.1 | PHP 4.3 + (PHP 5.0+ for later versions) |
WordPress 3.x | PHP 5.2.4 | PHP 5.4+ |
WordPress 4.x | PHP 5.2.4 | PHP 5.6+ |
WordPress 5.x | PHP 5.6.20 | PHP 7.0+ (PHP 7.3 and 7.4 for later versions) |
WordPress 6.x | PHP 5.6.20 | PHP 8.0+ |
Choosing the right PHP version for your WordPress site seems to be a relatively straightforward job. But is this always the case?
How Updating to the Recommended PHP Version May Backfire (But You Should Do It Anyway)
Ask any specialist, and they will tell you that you should always use the latest WordPress core and run it on a hosting account that supports and runs the newest PHP version. Yet, not everyone seems to be heeding this advice.
At ScalaHosting, for example, we often talk to people with an existing website who need a hosting account supporting PHP 5.4 or 5.6. To put things into perspective, these versions came out in March 2012 and August 2014, respectively. PHP 5.4’s end-of-life came in September 2015, and for PHP 5.6, it occurred in December 2018.
This is ancient technology, and the reason for using it is usually simple—an old plugin.
Far too many people build their entire websites around the functionality provided by a single add-on. If the said add-on is not adequately maintained by its developers, sooner or later, it becomes incompatible with the new PHP versions that come out.
The website owner has to either ditch the plugin that has been central to the entire project’s success or stick to the old PHP version. At least, that’s what they sometimes think.
In reality, the pool of WordPress plugins is so enormous that you’re bound to find an alternative. More likely than not, there is an equivalent extension that delivers similar functionality but is actively developed and, therefore, compatible with the latest PHP versions. Even if there isn’t, you can ask the old plugin’s developer whether they can adapt the add-on to work with a more modern hosting setup.
If they’re not responsive, another professional developer may be able to fix it. It probably won’t be cheap, but if the plugin really is that important for your business, the expense will be worth it because it will bring you a few crucial advantages.
The Advantages of Upgrading Your PHP Version
Although some people follow it religiously, the “if it works, don’t fix it” mantra doesn’t work well in the world of website development. The World Wide Web is a dynamic place, and your competition is constantly evolving and improving. If you want to attract and retain visitors, you must keep up, and the only way to do that is to use the latest stable version of all the software powering your website.
PHP is no exception. Here are some of the main benefits of sticking to the most recent version of the programming language.
Better Performance
A lot of the work done to PHP over the years has centered around speeding up the products created with it. For example, many headlines around PHP 8.0 focused on the brand-new compiler introduced by the app.
Thanks to it, PHP 8.0 executes code about 20% faster than PHP 7.4. Compared to the old PHP 5.6, the percentage gains run well into the three-figure range.
Improved Security
Every PHP release branch has a fairly simplified life cycle. During the first two years after the initial rollout, the version is in its active support stage. Bugs are fixed, and improvements are introduced in regular point versions.
For two more years after that, critical security patches will be released if someone finds a vulnerability, but the branch isn’t developed any further apart from that. Once that period is up, the PHP version reaches its end-of-life, meaning even the most severe bugs remain unaddressed. You can figure out for yourself what this means if you use a PHP version that is more than four years old.
New Features
In addition to the new compiler we mentioned earlier, PHP 8.0 introduced several new features, including named parameters and arguments, attributes, match expressions, better error handling, etc.
As a PHP user who doesn’t code, you may think this doesn’t concern you much. However, that is not the case because it means the core can be faster and more efficient. All these new features also allow theme and plugin developers to implement more modern designs and functionalities that were previously impossible.
Improved Resource Efficiency
In addition to performance, PHP’s developers also want to extract more efficiency from the technology. The ultimate goal is to make websites execute more code while consuming fewer hardware resources.
On the one hand, this will likely stabilize your website performance even during busy hours. On the other hand, it will save you money because you can serve more traffic with a cheaper hosting solution.
Future-Proofing Your Website
The required and recommended PHP versions for WordPress websites change as the CMS evolves. By updating to the latest PHP branch now, you can be sure you’ll have no compatibility issues for the foreseeable future.
This, in itself, is crucial if you want a sleek, functional, and secure website.
So, upgrading to a more recent PHP version is definitely worth considering. But how do you know you’re not already using the latest one?
How to Find out Which PHP Version You’re Using
There are several methods for finding out your website’s current PHP version. You can go through the menus and sub-menus in your control panel. The information is in there somewhere, but because every management platform has its own interface, it can be challenging to find it, especially if your experience is limited.
You can also use the php -v command after you access your server via SSH.
However, because you use WordPress, you’ll probably prefer not to bother with any of this and check the PHP version from the WP dashboard. Log in to it and go to Tools > Site Health.
Click the Info tab and open the Server section. You’ll see all sorts of details about your hosting environment, including the server’s operating system, the type of web server you’re using, the memory limit, etc.
The currently active PHP version is on the third row.
All that’s left now is to see how you can change it.
How to Safely Upgrade Your WordPress PHP Version
We already know about the advantages of using the latest PHP version, and as we’ll find out, enabling it is unlikely to take more than a few clicks. This doesn’t mean it’s a simple process from a technical standpoint.
The update is a chain of events that happen behind the scenes. The web server switches to a different binary, the main configuration files are updated, version-specific libraries and PHP extensions are loaded, and all related processes are restarted.
Given how many things are happening simultaneously, it’s better to be prepared and take a few precautions to ensure everything goes smoothly.
Preparing for a PHP Update
Let’s look at the steps you need to take before you proceed to the actual update.
- Back up your site
Start by backing up your website. Ideally, automated backups are included in your hosting service, guaranteeing that you have a recent working copy of your site. Even if you do, doing a manual backup is still a good idea, just to be safe.
You most likely have a utility for this in your web hosting control panel. You can use a WordPress plugin like Duplicator or UpdraftPlus if you don’t.
- Update the core, themes, and plugins
Log in to your WordPress dashboard and go to Dashboard > Updates. The page gives you a quick and easy way to install updates to the core, your WordPress themes, and plugins. This will minimize the risk of compatibility issues after changing the PHP version.
- Check compatibility
Updating your WordPress core and the add-ons will reduce the chances for post-upgrade problems but won’t eliminate them completely. Before you proceed, it’s best to check whether your site is compatible with the version of PHP you want to enable.
The easiest way is to use a plugin like PHP Compatibility Checker, which goes through your site code and detects potential conflicts. Note that it’s not 100% accurate. Its developers admit that false positives are possible, and because the plugin doesn’t actually execute any code, it can’t detect any potential runtime issues.
Because of this, it might be a good idea to review the documentation of your WordPress add-ons as well. With that, you should be able to safely proceed with changing the PHP version on your website.
Many opt for the easy route and ask their host’s support team to do it for them. The agents are unlikely to decline, but how quickly they’ll respond and when they’ll actually do it properly is a different matter. Then, if the changes need to be reverted, you’ll have to contact the technicians again and wait for them to act. Overall, it’s better to change the PHP version yourself.
The exact steps depend on the control panel your hosting account is equipped with. We’ll now look at SPanel and cPanel – two of the leading platforms of this kind.
Changing the PHP Version of Your WordPress Website in SPanel
SPanel is ScalaHosting’s proprietary server management platform. We aim to give website owners every tool they need to build and maintain their projects in perfect working order. SPanel is constantly updated, and our team ensures it supports all the latest stable PHP versions.
You can host multiple websites on the same server and use different PHP versions for each. Changing them is very simple.
STEP 1: Log in to the SPanel User Interface and open the PHP manager
The login URL is https://yourdomain.com/spanel (unless you’ve changed it). You can use the credentials you picked when creating the account. Alternatively, the User Interface can also be accessed from SPanel’s admin area.
The PHP Manager is situated in the Tools section.
STEP 2: Locate the site you want to manage and select Change PHP version
The page will display a list of all the domains and subdomains created on your account, along with their current PHP versions. Every domain and subdomain has its own document root folder, so they can use different versions. Open the Actions drop-down menu next to the domain you want to modify and click Change PHP version.
STEP 3: Pick the PHP version you’d like to use and confirm your choice
A popup will appear with a drop-down menu containing all the PHP versions currently supported by SPanel. Choose the one you want to use and click Change.
SPanel will complete the process automatically and inform you when the change is complete.
Changing the PHP Version of Your WordPress Website in cPanel
cPanel has been around since 1996, and although recent changes to its pricing policies have driven some users and hosting companies away, it’s still one of the most prominent platforms of its kind.
It is particularly common to see it on shared hosting plans. The lower prices and smaller margins mean that developing alternatives is often not financially viable for hosts.
Like SPanel, you can change PHP versions for all websites hosted on your account.
STEP 1: Log in to cPanel
The default cPanel login page is located at https://yourdomain.com/cpanel or https://yourdomain.com:2083. In some cases, it’s possible to access the cPanel interface straight from the client area on your web hosting provider’s site.
STEP 2: Open the MultiPHP Manager and select the domain of the website you want to modify
The tool for changing your site’s PHP version is called MultiPHP Manager, and it is located under the Software section on cPanel’s homepage.
Yet again, when you open the tool, you’ll see a list of all the domains and subdomains hosted on your cPanel account, along with the PHP version they’re using. Next to each one, there’s a checkbox. Select the one belonging to the site you want to modify. You can select multiple checkboxes and update several projects’ PHP versions simultaneously.
STEP 3: Pick the PHP version you want to use and apply it
The PHP Version drop-down menu is above the list of domains. Select the version you want to use and click Apply.
When you’re done, you can confirm that the PHP version has been changed by logging in to the WordPress dashboard and going to Tools > Site Health > Info.
Conclusion
You don’t need to be reminded how important the hardware resources are when choosing a hosting account. What many users forget, however, is that processing power, memory, and storage won’t help much if the software utilities and platforms are not working to their full potential.
The PHP version you use plays a significant role in determining how well the entire website works, so be sure not to overlook it. See which versions are supported before you sign up, and ask whether updates make their way to the servers frequently. Last but not least, ask your web host what you’ll need to do to switch between PHP versions.
Frequently Asked Questions
Q: How do I update PHP on my WordPress site?
A: The exact steps for changing your site’s PHP version depend on your hosting account. Sometimes, you need to ask your hosting company’s support team to do it. More often than not, however, there’s a tool in the control panel letting you do it yourself.
Q: Should I update PHP on my WordPress website?
A: Upgrading to the latest PHP version gives you access to the most modern features and performance improvements introduced in one of the world’s most popular programming languages. In addition to this, every new version comes with stability and security updates that are critical for your website’s user experience.
Q: Which PHP version is best for WordPress?
A: Every time they roll out a new WordPress release, the developers of the world’s most popular CMS issue a recommendation for the PHP version you should use if you want the best possible performance and security. The latest WordPress core can work with older versions of the programming language. However, if you want to take full advantage of it, you should use PHP 8.0 or newer.