PHP 7.1! is here

We’re extremely excited to announce that our Cloud Web Hosting platform now supports PHP 7, the latest release from the PHP team. PHP 7 comes loaded with new features and under the hood improvements that give web developers the ability to create cleaner, faster and more efficient code.

Wooh where’s PHP 6?

First things first – where’s PHP 6? Whilst PHP 6 was originally planned and being developed, due to the time taken to implement some of the bigger changes at the very core of the language, new features planned for version 6 were instead added to releases in version 5. Eventually it was decided that, since most of the features planned for 6 had now been added to the language, that they’d jump straight to version 7 instead.

New PHP 7 Features

PHP 7 has a lot of new features that I can’t cover in depth but, I’ve pulled out some of the more exciting new features:

Improved performance: As part of the update, large parts of the PHP interpreter have been rewritten to improve the speed at which PHP executes code. This is achieved by reducing the number of CPU cycles required. The changes have resulted in improvements on real world tests from anywhere between 25{5b18cbf54314d3254b4402bcf1ddb26dc4a7d6aacbffec55003dd9195b367bd6} all the way up to 70{5b18cbf54314d3254b4402bcf1ddb26dc4a7d6aacbffec55003dd9195b367bd6}. All this without changing a single line of code of the applications.

The “Spaceship” operator: Also known as a combine comparison operator, the <=> operator allows you to compare two different expressions and return whether the expression you’re checking is smaller, equal to or greater than what you’re checking it against.

Scalar and return type declarations: It is now possible to explicitly specify what sort data types a custom function will accept and return. You can also set the strictness of these declarations which will tell PHP whether to try and convert data types or throw exceptions.

Null coalesce operator: An improvement on the existing ternary operator which allows you to directly compare whether the item you’re checking. Previously if you wanted to see if a variable was set and take action accordingly you’d need to combine the ? operator with the isset function. The new ?? operator lets you do this without needing to call another function.

Filter unserialized data: The unserialize function, used to take serialized arrays and convert them back into standard arrays, now has the ability to apply filters to the data being converted. This means it is now easier to handle the unserializing of data, especially from untrusted sources, in a much safer way and reduce the risk of code injection.

Compatibility

Whilst PHP 7 makes a lot of changes, it is largely designed to be backwards compatible. Therfore it should be possible to upgrade without any issues however, we highly recommend that you check the compatibility of your scripts before making the upgrade.