If you have not been following PHP development recently PHP 7 is fast approaching with the first beta having been released just over a month ago. As is tradition here at Hawk Host we’re always pushing the envelope when it comes to shared web hosting. That is why as of today we officially support PHP 7 even though it’s currently beta.
The first thing you’re wondering is where is PHP 6? The answer is many of the great features we enjoy in PHP today were originally set to be part of PHP 6. Other features had subsequently not made it into any PHP version. To avoid confusion the PHP team have opted to move straight to 7.
There are many reasons to look forward to PHP 7 with the first thing being many of the great new features available:
- Scalar type declarations
- Return type declarations
- Null coalesce operator
- Spaceship operator
- Constant arrays using define()
- Anonymous classes
- Unicode codepoint escape syntax
- Filtered unserialize()
- Group use Declarations
- Generator Return Expressions
- Generator Delegation
- Integer Division with intdiv()
- CSPRNG Functions
That is a quick run down of the new features available which I’m sure many of the developers using our hosting are going to quickly make use of. If you’re looking for a complete run down with more detailed information you can check out the PHP 7 migration guide new features pages. For many of our users who are not developers, PHP 7 features are really not what you’re looking for. You’re more concerned about PHP performance, and the good news is PHP 7 brings significant improvements compared to previous versions.
PHPNG (next generation) was a project that was open source then later merged into PHP 7. Its goal was to optimize PHP drastically and allow for JIT compilers in the future. It has more than doubled performance in many cases. The WordPress hello world page took 9.4 billion CPU instructions to execute in PHP 5.6. With PHP 7 it now only requires 2.6 billion which is a 72% reduction. We recently wrote a post about how you can Super Charge WordPress With Litespeed Cache . We do however understand there are scenarios where it’s just not possible to do. We’ll provide benchmarks once again this time comparing PHP 5.6 and PHP 7 in our shared hosting environment:
Time taken for tests: 208.687 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 9333000 bytes HTML transferred: 9097000 bytes Requests per second: 4.79 [#/sec] (mean) Time per request: 4173.730 [ms] (mean) Time per request: 208.687 [ms] (mean, across all concurrent requests) Transfer rate: 43.67 [Kbytes/sec] received
PHP 5.6 was only able to handle 4.79 requests a second with one CPU core which is standard on all our shared web hosting accounts.
Time taken for tests: 138.669 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 9337000 bytes HTML transferred: 9097000 bytes Requests per second: 7.21 [#/sec] (mean) Time per request: 2773.389 [ms] (mean) Time per request: 138.669 [ms] (mean, across all concurrent requests) Transfer rate: 65.75 [Kbytes/sec] received
Switching to PHP 7 we were able to handle an additional 2.4 requests a second. It’s worth noting this is with absolutely no caching and a single CPU core. In a limited test by enabling the OpCache extension in our PHP extension manager in cPanel we were able to improve PHP 5.6 to 22.33 requests a second and PHP 7 to 51.05 requests a second.
With these great new features and performance improvements we do need to stress as of this moment PHP 7 is still in beta and we would not recommend running it on live web sites. If however you’re looking to make sure you’re compatible for the official release look no further than Hawk Host for that. You can quickly switch to PHP 7 using our select php version option in cPanel and confirm your application is compatible, then switch back to the desired PHP version whatever that may be (5.2 through 5.6).