This is a guest post. Opinions and recommendations are the author’s own and not necessarily those of WP Rocket.
What if I said you could double your WordPress site’s page speed in just 10 minutes? Sounds amazing, right?
Well, you can—all you need to do is upgrade to the latest version of PHP.
And soon, you won’t have a choice anyway, since PHP 5.6 will become the minimum requirement for WordPress in April 2019, to be replaced by PHP 7.0 as early as December 2019.
PHP is one of the most popular scripting languages on the web. In fact, 70% of all websites that use server-side programming use PHP. That’s 8 out of 10 sites.
PHP also powers WordPress websites. But a big problem we’re facing in the WordPress community is that many sites, businesses, hosting providers, and developers aren’t supporting the latest versions of PHP. It’s especially frustrating considering just how easy it is to upgrade.
At MailPoet, we firmly believe that all WordPress users should upgrade to the latest version of PHP as soon as possible. Not only will upgrading instantly improve your site’s speed and performance, but it also provides security and compatibility benefits, too.
Today, I want to convince you to take the 10 minutes out of your day that is required to upgrade your site to the latest version of PHP.
WordPress and its PHP Problem
Eight out of every 10 WordPress websites will soon be running on a version of PHP that is no longer supported—if site owners don’t act fast.
According to WordPress.org statistics, 36.4% of WordPress sites are on PHP 5.6. The problem? Active support for PHP 5.6 ended on 19 January 2017, and it will officially reach its end of life on December 31. This means it will no longer have security support and websites that continue to use it could be exposed to unpatched vulnerabilities.
Then there’s PHP 7.0, which reached its end of life on December 3, 2018. It, too, is no longer a supported version of PHP. Still, almost 20% of WordPress sites are on PHP 7.0.
If you’re thinking, “wasn’t PHP 7.0 just released?!” It was… two years and 11 months ago. As with any software, PHP has a release life cycle that it needs to stick to in order to move forward with improvements and new features (just like WordPress). Each major version of PHP is usually fully supported with bug patches and security fixes for two years after its release.
And then there’s the other 25.2% of sites already running on unsupported older versions of PHP, including 5.2, 5.3, 5.4, and 5.5.
So in total, at the time of writing, a whopping 81.3% of WordPress sites are running, or are about to be running, an unsupported version of PHP.
Only 18.6% of WordPress sites are running on the latest supported versions—PHP 7.1 and PHP 7.2.
Why Are So Many WordPress Sites Still on Older Versions of PHP?
There are many and varied reasons why websites continue to run on outdated and unsupported versions of PHP, but these are the most common factors.
1. Website Owners Don’t Know or Don’t Care
For many site owners, particularly those who aren’t technically inclined, all they care about is that their site is up and running, and that it’s functioning well and looks good. If they don’t have to upgrade their version of PHP, why would they want to?
In many cases, it’s up to developers and web hosts to push these site owners into upgrading (for their own good!).
2. It’s Time-Consuming for Plugin and Theme Developers
For developers with older plugins and themes, updating to the latest versions of PHP involves updating their code, together with extensive testing to ensure compatibility. After all, they don’t want to break their users’ sites.
3. Web Hosts Don’t Want to Break Sites
What it essentially comes down is that that web hosting companies don’t want to break their customers’ websites. Even though PHP 5.6 was released in 2014 and PHP 7.0 is about to reach end of life, web hosts have put off updating their servers to the latest versions of PHP (7.1 or 7.2) due to the potential to break plugins and themes.
With 32.4% of all websites using WordPress, that’s a lot of support tickets if web hosts push updates and things go wrong.
This means that if you want your site running on the latest version of PHP, you’ll need to take the initiative and upgrade it yourself, or push your hosting provider to help you.
Why Isn’t WordPress Requiring Newer Versions of PHP?
The WordPress Project hasn’t forced users onto the latest versions of PHP because… Well, it’s complicated. It’s a mix of everything I covered in the section above, and also having the responsibility of managing the world’s most popular content management system.
But things are set to change in 2019.
At WordCamp US in December 2018, it was announced that PHP 5.6 will become the minimum supported version in the first half of 2019, and the minimum version will be bumped up again to PHP 7.0 in the second half of 2019—if all goes according to plan.
These changes have been a long time coming, and we can thank Yoast for playing a big part in pushing users to upgrade. In early 2017 with the release of Yoast SEO 4.5, a notification was added to the WordPress dashboard for Yoast users. It urged site owners whose sites were on a server running an outdated version of PHP to update to a new version.
Site owners could only disable the nag by updating PHP.
This initiative, called the Yoast WHIP project, proved that asking users (or “bothering” them, as Yoast says, in the original Trac ticket they wrote about merging the WHIP into WordPress core)—to upgrade could actually make change in a meaningful way.
Remkus de Vries, Manager Partnerships and WordPress Community Liaison at Yoast, told me that for a long time, their team saw the number of installs to newer versions of PHP double as a percentage of the total.
As a result of WHIP, along with the positive uptick in the number of PHP upgrades, the Servehappy project was launched in mid 2017.
More recently, in early December WordPress core contributor Gary Pendergast proposed updating the minimum PHP versions. The plan, which Matt Mullenweg confirmed in his State of the Word at WordCamp US, will make PHP 5.6 the minimum required version for WordPress by April 2019, with PHP 7.0 becoming the minimum “as early as” December 2019.
After Matt announced the proposal at WCUS, it got an enormous applause—far more applause than most of the news about Gutenberg. For the WordPress community, moving forward with the latest versions of PHP is welcome news.
While bumping up the minimum PHP versions won’t necessarily change apathy, awareness or developer support for newer PHP releases overnight, the deadlines will certainly help ensure WordPress keeps up with PHP in future years as it develop.
According to the WordPress.org:
“The immediate goal is to put in place supporting structure and site owner education/resources etc so that we can more actively reduce the number of existing active WordPress sites on older PHP EOL versions and thus improve security and performance of the web.”
Why You Should Upgrade to PHP 7+
If the above hasn’t convinced, there’s more. Not only is PHP 7.2 now officially listed as a recommended requirement to run WordPress, upgrading comes with loads of speed, performance, and security benefits.
1. Speed and Performance
If your site is running on an older version of PHP, updating to the latest version will give you immediate performance gains—more so than any tweaking around the edges of your WordPress site will provide you with.
When PHP 7.0 was released, it was widely praised for delivering substantial performance gains. In fact, official PHP benchmarking using WordPress 4.1.1 shows PHP 7.0 enables servers to execute twice as many requests per second than PHP 5.6 at less than half the latency.
Web host Kinsta has also recently published performance benchmarks, comparing PHP 5.6, PHP 7.0, PHP 7.1, PHP 7.2 and PHP 7.3. Their findings show PHP 7.3 executes 3x as many requests per second compared to PHP 5.6.
If you need further proof of the performance gains you’ll get when you upgrade, early benchmarks from open source news and reviews site Phoronix have shown that PHP 7.3, which was released at the end of 2018, is about 5% faster than PHP 7.2.
2. Support and Compatibility
Compatibility is another big reason why you’d want to be on the latest version of PHP. Like any piece of software, developers will only support older versions for a certain amount of time. For example, older versions of the iPhones aren’t compatible with the latest version of iOS, rendering them virtually useless.
This comes down to the fact that actively supporting old software and ensuring backward compatibility is costly, mostly in terms of time for plugins and theme developers. They want to move forward with adding new features and security and performance enhancements to their products—and supporting older versions of PHP holds them back.
At MailPoet, we needed to move forward for our own benefit and have dropped support for PHP 5.2, 5.3, 5.4 and 5.5 altogether. This lowered our reach to many users, but increased our team’s happiness significantly—it meant we could focus on making a bigger and better product!
In fact, issues with older versions of PHP regularly crop up in the WordPress.org support forums. If you search for “T_Function,” there are more than 2,700 results.
As WPMU DEV’s Predrag Dubajic helpfully explains in this support thread for the Hustle plugin, T_Function errors usually appear when a user is running an outdated PHP version:
Another fundamental reason why you should upgrade is for the security of your WordPress site. Running the latest version of PHP ensures that your site is protected against vulnerabilities identified in older versions of PHP.
For example, here’s an eye-opener: according to security vulnerability datasource CVE Details, there were 18 known vulnerabilities found in PHP this year. In 2017, there were 43 security exploits discovered, and in 2016 a huge 107 vulnerabilities were found.
These vulnerabilities include DoS, code execution, SQL injection, XSS, and many other types of exploits.
It’s WordPress best practice to keep your versions of WordPress core, plugins and themes up-to-date. Likewise, to avoid security vulnerabilities, you should keep your version of PHP up-to-date, too.
Checking PHP Compatibility
Hopefully by now I’ve convinced you of the merits of updating to the latest version of PHP. But before you go ahead and update, there are a couple of things you need to do first: check what version of PHP you’re on and also check your site’s compatibility with the latest version.
Not sure what version of PHP your site is running on? Here’s how you can check.
Install the free Display PHP Version plugin, which you can download from the WordPress plugin repository. When you activate this plugin, it will display your version of PHP in the “At a Glance” widget in the WordPress dashboard.
You should also check your plugins and themes are compatible with the latest version of PHP before you upgrade. WP Engine’s PHP Compatibility Checker plugin is the best tool for this job. This plugin lets you scan your site and check which plugins are compatible with the three latest versions of PHP.
Once the scan is done, it will display a list of your plugins and highlight any that include code from older versions of PHP that is now incompatible with the version you just tested.
It’s important to toggle the details of any plugins that are displayed with the “Unknown” tag, such as Caldera Form above. Plugins like this are skipped because they are too large to scan.
If you find that any plugins you use aren’t compatible with the latest version of PHP, or give you unknown results or warnings, get in touch with the plugin author and ask for support.
How to Upgrade to the Latest Version of PHP
Once you’ve tested your WordPress site for compatibility—and you’ve run a backup, just to be on the safe side—you’re ready to upgrade your version of PHP.
It’s best to upgrade your staging site first before upgrading your production site, just to be on the safe site and ensure there are no problems with your live site.
1. Upgrading PHP with cPanel
If you’re with a host that provides cPanel access to your site, you can simply log in to cPanel and change your version of PHP there.
All you need to do it scroll down to the Software section and choose “Select PHP Version.”
On the next page, choose the PHP version you want to use and click “Set as current.”
That’s all you need to do. Refresh your site to check that it’s working okay, but if you checked compatibility your site should be fine.
2. Upgrading PHP on Your Own Server
If you administer your own server, you can upgrade to PHP 7.2 yourself using the migration guides provided in the documentation at php.net. It’s important that you pay close attention to new features and functions, as well as any deprecated features that might impact your site.
Migrating from PHP 5.6.x to PHP 7.0.x
Migrating from PHP 7.0.x to PHP 7.1.x
Migrating from PHP 7.1.x to PHP 7.2.x
3. Asking Your Web Host to Upgrade PHP
If you don’t have access to cPanel or another relatively simple way to upgrade PHP, contact your web host. The upgrade process should be easy on their end without impacting your site.
WooCommerce recommends sending this email to your hosting provider, but here’s an amended and up-to-date version:
I’m running a WordPress site on one of your servers and WordPress.org recommends PHP 7.2 as the required version of PHP on their requirements page: https://wordpress.org/about/requirements/
Could you let me know if my hosting supports PHP 7.2 and how I can upgrade?
Looking forward to your reply.
If your host makes it difficult to upgrade, or even refuses to do it for you, it’s time to find a new host.
It’s Time to Make the Switch to PHP 7+
Hopefully, I’ve provided a compelling enough argument here to convince you to upgrade to the latest version of PHP. Not only will upgrading give you immediate performance gains, but your site will also be better protected against security vulnerabilities found in older versions of PHP.
Before upgrading your site, make sure you check your site’s compatibility with the PHP version you want to switch to and run a backup. Even better, create a staging version of your site and test it there before upgrading your live site.
Lastly, if you come up against any web hosts or plugin or theme developers who make it difficult for you to upgrade PHP, switch to a host or another product that is compatible! This way, you’re making a stand, and ensuring hosts and developers who aren’t using the latest versions feel the pressure to upgrade.