Site Speed

Switching to PHP 7

Updated

Written by

Dave Warfel

Reading Time

11 minutes

If you buy something from one of our links, we may earn a commission.

I will admit that I’m a little late to the party, but switching to PHP 7 is something that I can now finally check off my list of site performance enhancements. In this article, I will explain the benefits, possible downsides, and my entire process for switching from PHP 5.6 to PHP 7.

This will mainly be geared towards…

  • those who have heard about PHP 7 and are getting ready to switch
  • anyone else looking to increase their site’s performance

Benefits of Switching to PHP 7

Switching to PHP 7 offers several benefits for your website, but unless you’re a developer, the only one that most site owners are concerned with is the performance increase.

PHP 7 is said to be twice as fast (a 100% improvement) as its predecessor, PHP 5.6. Several people who have switched have published speed tests, showing the performance increase they gained by switching to PHP 7.

When it comes to performance, it’s pretty hard to argue that PHP 7 is far better than PHP 5.6. If this were the only metric we cared about, PHP 7 would be the obvious choice.

However, it’s not quite that easy. There are a few additional things you should consider before making the switch.

Caveats of Switching to PHP 7

With that kind of performance increase, why would you not switch?

PHP 7 could break your site

Part of the reason why PHP 7 performs so much better is because it no longer supports some things that were supported in previous versions. It’s more optimized, more lightweight, and thus, support for some older components needed to be removed.

Some WordPress plugins & themes could be using this old code that is not supported, which means, switching to PHP 7 could break some sites.

In the next section, we’ll explain how you can test your site before upgrading, and take some precautions to make sure your site doesn’t break.

Does your hosting company offer PHP 7?

At this point, most hosts offer PHP 7 as an option. However, there are still some that only allow you to run PHP 5.6. If your host doesn’t offer PHP 7, and doesn’t have it on their roadmap for the near future, you should consider changing hosts.

Check out our recommended WordPress hosts »

Before Switching to PHP 7…

There are a few things you should do to make sure your switch goes off without a hitch.

Test Your Site on PHP 7

This one is the most obvious, but you should run your site on PHP 7 in a testing environment before making the switch live. There are a few ways you could do this.

1. I used MAMP, which provides a free, local development environment right on my Mac. You simply adjust your settings to use PHP 7 instead of PHP 5.6.

MAMP PHP 7 settings

2. Some WordPress hosts offer a staging environment, and allow you to try out PHP 7 there before making the switch to your live site.

Local by Flywheel
Image borrowed from local.getflywheel.com

3. You could also try Local by Flywheel, which allows you to create a testing environment, and switch between PHP versions.

PHP Compatibility Checker Plugin

Another tool to test your site’s compatibility is the PHP Compatibility Checker plugin for WordPress.

  • Install the plugin on your live site
  • Initiate the test
  • It will check your site’s plugins & themes for incompatibilities with PHP 7

PHP Compatibility Checker WordPress plugin

IMPORTANT: This plugin does not test everything. It will not guarantee that your site will work fine, and it also might elude to some issues/warnings that won’t really cause any problems.

WordImpress has written a great article on what it doesn’t check for, and why it’s important to fully test your site in addition to using the plugin.

If you’re not using WordPress, there is also an open source version you can use on any PHP project.

Switching to PHP 7 on WP Engine

WP EngineThis section will outline my experience switching to PHP 7 with WP Engine. If you’re using a different host, you can skip this part and scroll down to the speed test results.

Contact Support: There is no automatic switch in the WP Engine control panel for PHP version. Their support team has to make the switch for you. I opened up a new chat, and 8 minutes later, I was speaking with someone from their team.

Support Ticket Created: The agent I spoke with was not able to make the change right away, so she opened a ticket.

PHP Update Complete: 7 hours later, I received an email that the ticket was updated, and my site was now running on PHP 7.

IP Address Change: It appears they have separate servers that run PHP 7 because my IP address changed. They did warn me of this, and pointed me to a help article on how to update my DNS. They also proxied the traffic so my site did not experience any downtime.

Speed Tests – PHP 5.6 vs PHP 7

Before I get into the speed test results, I want to be clear about a few things.

These page speed tests consider many factors, only one of which is the version of PHP you are running. Therefore, they are not the absolute best tools to solely test PHP performance. But they are free, widely available, and track overall page performance, so I chose them for those reasons.

I am running Google AdSense on this site, and displaying 3 different ads on each page that was tested. In looking at more detailed test results, it quickly became clear that there are many factors outside of my control. Depending on which ad Google decides to show, it could load a different number of CSS, JavaScript & font files each time the page is viewed.

In looking at the waterfall analysis on all of these tests, it is clear that many of the bad marks can be attributed to Google ads. Also, every time I view a page on my own site, it is usually noticeable that the ads are the last thing to render, sometimes not appearing until 2-4 seconds after the rest of the page has already loaded.

I think Google ads are also to blame for the varied number of file requests that you’ll see below.

So, while some of these load times might appear rather high, the perceived load time for the majority of the page is much faster.

All locations are abbreviations for U.S. states.

  • CA = San Jose, California
  • VA = Dulles, Virginia
  • TX = Dallas, Texas

All tests use a Cable modem connection, and render the site on a desktop machine.

Variations Between Testing Tools

It’s important to note that each of these testing tools operate in a different fashion. While they all maintain a similar format in their results, they arrive at those results in somewhat different ways. I think it’s best to only compare a page’s performance within each tool (Pingdom PHP 5.6 vs Pingdom PHP 7), and not make comparisons across tools (Pingdom PHP 5.6 vs WebPageTest PHP 7).

Pages Tested

I decided to test out two pages: one larger page with over 6,000 words and 20+ images, and one smaller page with less than 1,000 words and only a couple, small images.

PHP 7 Speed Test with Pingdom

Here are the speed tests for WP Engine Review running PHP 5.6. This will be referred to as the “larger page.”

PHP 5.6 speed test results via Pingdom
Tool (Location) Load Time Page Size Requests Score
Pingdom (CA) 5.82s 2.5 MB 128 79/100
Pingdom (CA) 4.36s 2.3 MB 132 79/100
AVERAGE 5.09s

And now running PHP 7.

PHP 7 speed test results via Pingdom
Tool (Location) Load Time Page Size Requests Score
Pingdom (CA) 6.12s 2.5 MB 148 92/100
Pingdom (CA) 4.28s 2.4 MB 151 78/100
AVERAGE 5.20s

I also tested a smaller page, our Basic Comment Quicktags plugin review.

Here it is on PHP 5.6.

PHP 5.6 speed test results via Pingdom
Tool (Location) Load Time Page Size Requests Score
Pingdom (CA) 2.59s 771 KB 92 74/100
Pingdom (CA) 1.52s 829 KB 94 76/100
AVERAGE 2.05s

And now running PHP 7.

PHP 7 speed test results via Pingdom
Tool (Location) Load Time Page Size Requests Score
Pingdom (CA) 7.47s 948 KB 123 85/100
Pingdom (CA) 4.30s 940 KB 120 74/100
AVERAGE 5.88s

PHP 5.6 vs PHP 7…

Load times – Difference between PHP 5.6 & PHP 7
Page PHP 5.6 PHP 7 Difference
Larger Page 5.09s 5.20s +0.11s
Smaller Page 2.05s 5.88s +3.83s

With Pingdom, both pages were actually slower on PHP 7. The larger page was marginally slower (0.11s is not statistically significant), but the smaller page was almost 4 seconds slower.

However, both the overall page size and the number of requests were higher when tested on PHP 7. The only reason I can think of why this would be the case is because Google’s ad servers loaded more files, which is likely the cause for the increase in page load time.

PHP 7 Speed Test with WebPageTest

Larger page on PHP 5.6…

PHP 5.6 speed test results via WebPageTest
Tool (Location) Load Time Page Size Requests Score
WebPageTest (VA) 5.72s 2.5 MB 102 n/a
WebPageTest (VA) 6.37s 2.5 MB 104 n/a
AVERAGE 6.04s

On PHP 7…

PHP 7 speed test results via WebPageTest
Tool (Location) Load Time Page Size Requests Score
WebPageTest (VA) 4.43s 1.9 MB 91 n/a
WebPageTest (VA) 6.07s 2.5 MB 102 n/a
AVERAGE 5.25s

Smaller page on PHP 5.6…

PHP 5.6 speed test results via WebPageTest
Tool (Location) Load Time Page Size Requests Score
WebPageTest (VA) 2.96s 734 KB 59 n/a
WebPageTest (VA) 3.52s 736 KB 59 n/a
AVERAGE 3.24s

On PHP 7…

PHP 7 speed test results via WebPageTest
Tool (Location) Load Time Page Size Requests Score
WebPageTest (VA) 3.61s 675 KB 60 n/a
WebPageTest (VA) 4.21s 676 KB 61 n/a
AVERAGE 3.91s

PHP 5.6 vs PHP 7…

Load times – Difference between PHP 5.6 & PHP 7
Page PHP 5.6 PHP 7 Difference
Larger Page 6.04s 5.25s -0.79s
Smaller Page 3.24s 3.91s +0.67s

Here you can see that a lower page size & fewer requests directly correlated to a decrease in page load time. Again, I made no changes to the pages between tests, so the only thing that could account for this is Google serving up fewer files for the ads it displayed during the test.

If page size had been equal on all tests, the numbers would likely show no increase in performance with PHP 7.

PHP 7 Speed Test with GTmetrix

Larger page on PHP 5.6…

PHP 5.6 speed test results via GTmetrix
Tool (Location) Load Time Page Size Requests Score
GTmetrix (TX) 5.8s 2.7 MB 139 n/a
GTmetrix (TX) 9.1s 2.7 MB 158 n/a
AVERAGE 7.45s

On PHP 7…

PHP 7 speed test results via GTmetrix
Tool (Location) Load Time Page Size Requests Score
GTmetrix (TX) 3.5s 2.4 MB 113 n/a
GTmetrix (TX) 4.5s 2.5 MB 144 n/a
AVERAGE 4.00s

Smaller page on PHP 5.6…

PHP 5.6 speed test results via GTmetrix
Tool (Location) Load Time Page Size Requests Score
GTmetrix (TX) 2.4s 866 KB 95 n/a
GTmetrix (TX) 5.1s 960 KB 133 n/a
AVERAGE 3.75s

On PHP 7…

PHP 7 speed test results via GTmetrix
Tool (Location) Load Time Page Size Requests Score
GTmetrix (TX) 1.4s 529 KB 60 n/a
GTmetrix (TX) 1.8s 529 KB 60 n/a
AVERAGE 1.6s

PHP 5.6 vs PHP 7…

Load times – Difference between PHP 5.6 & PHP 7
Page PHP 5.6 PHP 7 Difference
Larger Page 7.45s 4.00s -3.45s
Smaller Page 3.75s 1.6s -2.15s

GTmetrix showed consistent improvement in page load speed. Both the larger & smaller page loaded considerably faster on PHP 7.

However, it’s important to note that all PHP 7 tests had a smaller page size and fewer requests, which likely contributed to the faster load times. So again, it’s hard to say if PHP 7 was the reason for the increased performance.

PHP 7 Speed Test with WP Engine Page Performance

Larger page on PHP 5.6…

PHP 5.6 speed test results via WP Engine’s Page Performance Tool
Tool Load Time Page Size Requests Score
WP Engine 5.83s 115 KB 15 90/100

On PHP 7…

PHP 7 speed test results via WP Engine’s Page Performance Tool
Tool Load Time Page Size Requests Score
WP Engine 8.26s 320 KB 37 79/100

Smaller page on PHP 5.6…

PHP 5.6 speed test results via WP Engine’s Page Performance Tool
Tool Load Time Page Size Requests Score
WP Engine 6.23s 186 KB 25 75/100

On PHP 7…

PHP 7 speed test results via WP Engine’s Page Performance Tool
Tool Load Time Page Size Requests Score
WP Engine 6.71s 321 KB 65 24/100

PHP 5.6 vs PHP 7…

Load times – Difference between PHP 5.6 & PHP 7
Page PHP 5.6 PHP 7 Difference
Larger Page 5.83s 8.26s +2.43s
Smaller Page 6.23s 6.71s +0.48s

The WP Engine page performance tests appear to measure things drastically different than the others.

  • Their score is a “Cache Score,” which to be honest, I couldn’t even tell you exactly what that means.
  • The page size they report is much lower than all 3 of the other tests (couldn’t tell you why), and I also can’t explain why the page size almost doubled when testing on PHP 7.
  • The number of requests went way up when testing on PHP 7 (couldn’t tell you why)

The load times I reported here are for a “complete load,” however, they also provide a time for when the visitor perceives the page as fully loaded (all visual elements on page loaded, but things are still running in the background). There was no significant change in either page load metric.

Once again, with numbers that vary this much, I have to believe that the Google ads are the culprit. Requests jumping from 25 to 65 and page size more than doubling… there’s absolutely no reason for that on a page to which I made zero changes.

Speed Test Wrap-Up

While none of my speed tests provided clear evidence that my site now loads faster on PHP 7 compared to PHP 5.6, I am still 100% confident that switching to PHP 7 was the right move.

If I had the proper tools to test all the right metrics, I’m willing to bet I’d see some improvement.

Also, had I performed the tests on a site that was not running Google ads, I bet the results would be quite different. (I hope to be able to perform a test like that in the near future.)

Google Analytics Page Speed Comparison

I am going to wait one week and then take a look at the page speed data in Google Analytics. I’ll compare a recent week on PHP 5.6 with my first full week on PHP 5.7. I’ll look at the site as a whole, and take a peek at the same two pages I tested above. I’ll also try to see if my organic search placement changed at all after making the switch to PHP 7.

Check back in a week or two for those updates.

Dave Warfel

LinkedIn  •  X (Twitter)
Dave has been working with WordPress since 2011. He's built 100s of client sites and almost a dozen of his own. He's tested almost every plugin you can think of, hosted with at least 10 different companies, and gone down every SEO rabbit hole you can imagine. When's he's not tinkering with new software, you'll find him in the mountains of Colorado, trail running, summiting peaks, and rippin' downhills on his mountain bike. 🏔️🏃🚴🤸

Leave a Comment