It took 10 years but it seems like the wait was worth it. 14 days ago a new version of PHP was released – PHP 7. Initial benchmark tests on WordPress show a 100% increase in performance. But then Badoo, a popular social networking website saw the potential and after 60,000 tests and over 3 million lines of PHP code they’ve come to a conclusion: PHP 7 is the bee’s knees!
Testing PHP. This thing on?
Badoo is the only major website apart from Etsy to completely switch over to PHP 7 and the conclusion that they have come to is that optimising their backend using the new PHP has resulted in the company saving a million dollars. The release of PHP 7 is a big deal in the programming world. So huge that we’ll be running an entire series of what PHP 7 brings to the table.
Unlucky number 6
On paper it must have seemed like a good idea but there’s no other way to put it, ambitious though it was, PHP 6 was a spectacular failure. The idea was that since PHP is mainly used in web development so an update to PHP 5 that would have native support for Unicode as its main feature, bringing complete Unicode support to the PHP core itself and allowing the language to have extended capabilities would have been a great idea. But not when that capability includes being able to use emojis as function and variable names and allowing international string functionality. Meaning that languages such as Chinese that use uppercase and lowercase characters differently from English would be recognized.
Rise of the Phoenix
As you can see over the course of this article PHP 7 is performing very well on tests across various platforms. And when I say well I mean that benchmarks are showing PHP 7 performing twice as fast as PHP 5.6. That’s the minimum. A lot of the times it’s even faster. Consider that 25% of the internet is run on WordPress. So the benchmark test below should be a cause for relief, if not celebration:
Spreading like wildfire
The new version HAD to be a success. With the failure of PHP 6 the developers at Zend understood what was required from the new version and what needed to be done to ensure PHP 7 would be a success. In the upcoming blogs we will go more into the technicalities but there are 5 major changes that we’ll touch upon here to see what makes PHP 7 so special.
- Easy user-land CSPRING
- New operators
- Error handling
- Type declarations
This is where things get a little complicated, because PHP 7 is bringing to the table things that are completely new but very very cool. Like one of the new operators is called the Spaceship Operator and its written as : < = >
The spaceship operator is comprised of three seperate operators, greater than, less than, and equal. It’s purpose is to check each operator one by one. First, less than. If the value that is on the left is less than the value on the right then it’ll return -1. If it isn’t then it will proceed to test if the value on the left is equal to the value on the right. If this is the case it will return 0. If it is not then it will move on and perform a final test to see if the value on the left is GREATER THAN the value on the right. If the other two haven’t passed then this one must be true and it will return 1. This function is most commonly used for sorting.
I tried to keep this first introduction to PHP 7 as simple as possible because in the second part of this series we’ll really be going under the hood and understanding how the new PHP is a very positive sign for things to come. Even still I couldnt help myself and started explaining the spaceship operator, but with a name like that how can you not?! Right now it’s only been Badoo and Etsy, but now that other websites have been assured PHP7 is stable expect many more cross overs. Come back next week to find how, why and when.