- By
- Last updated:
PHP 7 is one of the most significant updates in the history of a server-side software that powers more than 82% of the internet, and, in this guide, we’ll discuss the ins and outs of using it with WordPress.
We’ll look at PHP 7’s incredible advantages, and help you to understand the importance of adhering to the recommended minimum version (5.6). You’ll also learn how to check whether your WordPress site is ready for PHP 7, and measure the pros and cons of upgrading to this new version.
At the end of this guide, you’ll be equipped with a firm understanding of PHP, and convinced enough to update to the recommended minimum — or maybe even take the next step to PHP 7!
Let’s get started…
A Beginner’s Guide to PHP — What Is PHP?
For those of you who are absolutely new to the topic, PHP is a server-side scripting language designed to generate HTML pages upon request.
Think of it as a simple three-step process:
- Input: You enter a set of commands written in the form of a PHP script, as the input to the PHP Engine.
- Processing: The PHP Engine executes the script on the server.
- Output: The output is an HTML page that’s rendered by the web browser.
In the three-step process described above, we can identify a few components.
- The PHP script(s)
- PHP Engine
- Server
- Output HTML
Now, let’s see how they relate to a typical WordPress environment.
1) PHP Scripts: WordPress is essentially a vast, organized collection of code written in multiple scripting languages, such as PHP, JavaScript and CSS, with the primary one being PHP. It’s what gives WordPress its dynamic nature.
2) PHP Engine: Think of it as the central component that executes the instructions laid down in the PHP script — doing so with the help of the server it’s running on. The PHP Engine is one of the most crucial components, and affects the speed, performance and reliability of a website. It’s also the central topic of our discussion!
3) Server: This is the remote computer, also known as the ‘web host’, where your WordPress site is hosted. If there were a web host without PHP installed, WordPress would not run on it.
4) Output HTML: Every time a WordPress website is loaded, the PHP engine is summoned. Scripts are executed by the PHP engine using the server, and the final (or output) HTML is exported to the visitor’s web browser. And that’s what completes the process.
What Is PHP 7?
Now that we’re clear on what a PHP script is, let’s talk about the PHP Engine. For the remainder of the article, we’ll use the terms ‘PHP engine’ and ‘PHP’ synonymously.
PHP 7 is a PHP engine that was launched in December 2016, and carries a plethora of new features, performance improvements and security enhancements. As with every good lesson, let’s start with a bit of history.
A Brief History of PHP
PHP was released in 1994 as a scripting language by Rasmus Lerdorf in an effort to create a tool that would make updating his personal homepage easy. *Little did he know that this side-project would evolve to power more than 82% of all websites — including biggies such as *Facebook and WordPress.
Over the years, PHP has had a couple of releases. The first one being in 1995, followed by version 2.0 in 1997. Version 3.0 was released in 1998 followed by version 4.0 in 2000.
Is it the anticipation that makes PHP 7 special?
This is where things started to get interesting. PHP version 5 was released four years later in 2004. It went on to have multiple iterations — so much so that the committee decided to skip version 6 and jump to version 7. To put things into perspective, the first iteration of PHP 5 was version 5.0, released in 2004. Its last iteration, PHP 5.6, was released ten years later in 2014.
Two years down the line, PHP 7 came along — the most promising release of PHP to date. In essence, the world had to wait a good 12 years to get their hands on PHP 7.
Performance Improvements in PHP 7
The wait did not go to waste. PHP 7 came with a truckload of performance and security improvements. Let’s dig into each performance improvement, backed by solid benchmarks.
1) Massively Improved Bandwidth (requests per second)
PHP 7 performed nearly twice as well as PHP 5.6, running WordPress 4.1.1.
In the chart above, we can see almost 2.18 times the number of requests per second at less than half the latency.
2) Lower Latency for Concurrent Users
Latency is the amount of time elapsed between the first request and the first response between the server and client. The lower the latency, the better the service. Let’s check out how PHP 7 handles it.
We’ve taken three data points based on the number of concurrent users for each PHP engine.
- The orange bars represent the latency when ten people are simultaneously using your site.
- The blue bars are for double (i.e. 20 concurrent users).
- The pink bars are for 40 simultaneous users.
In all cases, PHP 7 knocks its predecessors out of the park.
*All of this in the *exact same hardware! This means that if you were to upgrade to PHP 7 with all the necessary compatibility checks in place (more on this later), you should see a two-fold increase in performance.
3) WordPress 4.0+ Releases are Optimized for PHP 7
WordPress 4.0 itself has been fine-tuned to leverage PHP 7’s latest features. According to Zend, it has almost double the performance on the same hardware, compared with its predecessor, WordPress 3.6.
In the chart above, we see that there’s a two-fold performance improvement in a major WordPress update. This benchmark is irrespective of the version of PHP. Rather, it is an indication that the WordPress community is continuously optimizing code for the upcoming versions of PHP.
4) 75% Fewer Instructions, Same Result
PHP 7 also has a killer instruction set. It’s outrageously optimized for executing the same task in fewer instructions. For example, one WordPress request on PHP 5.6 executes in 100 million CPU instructions. Whereas in PHP 7, the same request is executed in 25 million CPU instructions. That’s a 75% reduction in the number of commands required to do the same job!
5) Significant Performance Gains
Jason Cosper, resident nerd at WP Engine, loves messing with the latest PHP engines to see which ones work best.
In one of his experiments, he found PHP 7 to be arguably 6.6 times faster than PHP 5.5 — running WordPress 4.3.1 and bbPress.
State of WordPress PHP in Q1 2017
Now that we have a functional understanding of the benefits of PHP 7, let’s take a look at how many WordPress users are using it.
The Good: According to the official WordPress stats, 9% of the WordPress community has upgraded to PHP 7 as of 20 April 2017.
The Okay: Around 40% of WordPress users are using PHP 5.6. This is relatively good news, since PHP 5.6 gets security support until 31 December 2018.
The Ugly: However, the really bad news is more than 50% of the active WordPress sites use a version of PHP older than 5.6, which exposes all these sites to severe vulnerability issues.
- PHP 5.4 has not been patched since 2015.
- And PHP 5.5 has not been patched since 2016.
- If you’re using a version older than 5.6 (more on how to check your PHP version later), please update your PHP version immediately.
A Beacon of Hope
Joost de Valk, founder of Yoast SEO — a WordPress SEO plugin with over than 3 million active installations — decided to do something about this. To quote from the original article:
As of Yoast SEO 4.5, we’ll start showing a notice on the WordPress dashboard to administrators of sites running on PHP 5.2. This notice will be big, ugly, and non-dismissible. In this notice, we will explain why the administrator should upgrade the PHP version of the site.
WordPress and Outdated Versions of PHP
At this point, it’s important to point out that WordPress will continue to support older versions of PHP. This does not mean you can sit back and relax. It’s in our best interest to upgrade to 5.6 — if not PHP 7.
If you’re on PHP 5.6, there are a couple of things coming your way soon:
- According to the official PHP support timeline, PHP 5.6 would get official support until 17 Jan 2017. That’s ended.
- In better news, PHP 5.6 would get security support until 31 December 2018.
- Of course, you’ll still be missing out on all the performance enhancements you could get for absolutely zero investment.
Switching to PHP 7 — Is It Worth It?
Now that we have a firm understanding of the various advantages of PHP 7, let’s address the crucial question: Should you switch to PHP 7?
The method for arriving at any decision should be based on logic. We’ll look at tackling these three basic questions:
1. What Are the Advantages of Switching to PHP 7?
We’ve covered five points backed by benchmarks from around the web. All of them point to a host of benefits, and to a resounding yes when it comes to the decision to switch.
2. Are Your WordPress Theme and Plugin(s) Compatible with PHP 7?
Just because WordPress is compatible with PHP 7 (and has backward compatibility with PHP 5.6), does not mean all its themes and plugins are. You may use a custom-built theme or plugin that has features that are deprecated in PHP 7. You may also use a plugin from the WordPress repository that’s not been updated for a while. What’s the solution?
3. How Can You Check if Your WordPress Site Is Ready for PHP 7?
Luckily, the generous developers over at WP Engine have created a rather awesome plugin that solves this very problem.
Introducing the PHP Compatibility Checker: A plugin that scans your WordPress code base and active theme plugins looking for known compatibility issues.
Supported PHP versions of the PHP Compatibility Checker Plugin
You can check for compatibility issues for five distinct versions of PHP, ranging from 5.3 to 7.0.
The compatibility issues (if found) are categorized into errors and warnings. The plugin will list the file and line number of the offending code, along with information as to why that code is incompatible with the chosen version of PHP.
However, there are a few limitations:
- The plugin cannot detect runtime compatibility issues, since it doesn’t execute any of the existing themes and plugins.
- It relies on WP-Cron to scan files in the background, so WP-Cron must be enabled and working on the server.
- Occasionally, false positives are reported since the plugin cannot detect unused code paths that may be used for backwards compatibility.
Sample list of plugins supported by PHP Compatibility Checker.
All in all, it’s a pretty neat plugin that can tell you whether or not your WordPress stack is prepared for the upgrade!
4. What Are the Dangers of Not Switching to PHP 7?
The following three points explain the disadvantages of not upgrading to the recommended PHP 7. They also highlight some of the possible dangers of not upgrading to the required minimum version, PHP 5.6.
*4.1 Performance Drop:* First off, you’d miss out on at least a two-fold increase in performance without investing a single dime. And guess what? If you’re on PHP 5.2, it’s reported to be 400% slower than PHP 7!
4.2 Security Issues: PHP 5.x had a plethora of vulnerabilities that were duly patched with the newer versions. In fact, 2016 was actually a record year for PHP security vulnerabilities, with more than 100 issues reported, ranging from Denial of Service (DoS) to memory corruption, malicious code execution, and so on.
To give you an idea of how bad the situation is, PHP 5.4 hasn’t been patched since 2015, and it’s no longer supported. And yet 21% of WordPress users still use PHP 5.4! If you’re a part of that group, please update to 5.6 today.
4.3 Broken Plugins: Using an older, unsupported version of PHP creates plugin conflicts. One of the most prominent errors is the ‘unexpected T_Function‘, as seen below.
Screenshot of support thread of the Content Locker plugin
The above screenshot is a support query for the Content Locker plugin. The author clearly mentions that the minimum version of PHP required for the plugin to work is 5.4.
5. Success Stories
It’s always encouraging to see how various organizations across the globe are benefiting from the upgrade.
5.1) A Fortune Saved for Badoo
Our first example is dating app Badoo, which has managed to save over $1 million by upgrading to PHP 7. How? Simple! PHP 7 reduced the amount of computing power required to accomplish the same task. Thus, fewer servers were required to do the same job, which ended up freeing up some 300 servers!
5.2) Major Performance Boost for Clinton Electronics
Our second success story comes from a WP Engine client, Clinton Electronics. In a nutshell, they wanted a dynamic ecommerce store with fast load times. The chosen stack was WordPress, along with WooCommerce. The agency they were working with chose WP Engine as the managed WordPress hosting provider, which, in turn, recommended PHP 7. This upgrade ultimately managed to reduce the website’s load time by as much as 60%!
How to Switch to PHP 7 with WordPress?
First off, ensure your current WordPress stack is compatible with PHP 7 using the PHP Compatibility Checker plugin. Once the plugin gives you a green light, proceed with the upgrade.
- If you’re using shared WordPress hosting, such as Bluehost, you can update your version of PHP in four simple steps. Almost all shared WordPress hosting providers come with a cPanel or a custom access panel wherein you can change the version of PHP.
- If you’re using a managed WordPress hosting provider, such as WP Engine, switching to PHP 7 is a piece of cake — reach out to their support, and they’ll have it done in a jiffy.
WP Engine PHP FAQ page, retrieved: 26 April 2017
Good news for WP Engine users is that the minimum allowed version of PHP is 5.6, according to their FAQ page.
Why WP Engine? There are a host of benefits that make WP Engine even more attractive:
- Innovative WordPress technology.
- Blazing fast servers capable of handling hundreds of millions of requests per day.
- Hardcore security with advanced DDoS protection.
- Superior support.
They’ve been in the business for a couple of years now, and have won over top brands, such as National Geographic and AMD. What I personally like most about WP Engine is their culture of giving back to the community — be it sponsoring WordCamps, hosting events, or building awesome free plugins such as the PHP Compatibility Checker.
If you’re considering an upgrade, or looking to change your current hosting provider, we would highly recommend WP Engine as your managed WordPress hosting provider, with plans starting at $29 a month.
Wrapping Up
Let’s quickly recap all that we’ve learnt so far:
- PHP powers 82% of the internet, powering sites such as Facebook and WordPress.
- The recommended minimum version of PHP is 5.6 — anything below that is a big no-no!
- PHP 7 has significant improvements in terms of performance, security and features — it easily increases WordPress’ performance by 2x with zero additional hardware.
- Switching WordPress to PHP 7 brings home a host of benefits without any investment.
- However, before switching, you need to ensure your WordPress setup is ready to be upgraded to PHP 7 using the PHP Compatibility Checker plugin.
- Shared hosts such as Bluehost support PHP 7, but it needs to be enabled manually.
- Managed WordPress hosts such as WP Engine have rock-solid compatibility with PHP 7.
At the end of the day, PHP is continuing to improve with every release. If you’re using WordPress along with only the popular plugins, you could gain a lot by upgrading to PHP 7. However, if you’re using a lot of custom or infrequently updated plugins, it’s perhaps best to hold on for a few more months before upgrading. However, it’s imperative that you use PHP 5.6 and nothing below that!
Already using PHP7 with WordPress? Thoughts?