Posted By: Tony Baird
Last Updated: Thursday December 8, 2016
We’re happy to announce we now officially support PHP 7.1 on all our shared, reseller and semi-dedicated hosting services. PHP 7.1 is the first point release in the 7.x series and it comes with many outstanding improvements and new features.
To enable PHP 7.1 all you need to do is login to cPanel go to ‘Select PHP Version’:
From here just pick PHP 7.1 from the drop down and set it as your current PHP version. After this you’ll be able to manage extensions as you would for any PHP version we offer and your entire account will use PHP 7.1.
If you were curious about some of the new features and improvements here’s a quick overview of them:
In PHP 7.0 there was an introduction of types but it had one limitation you could not declare a parameter to be null without also making it optional. This has been resolved by utilizing the ? character. For example:
[code language=“php”] function myFunction(?int $variable) { var_dump($variable); }
myFunction(100); myFunction(null); [/code]
This code would return int(100) for the first and NULL for the second call to the function.
You can also use nullable types for a return type for example:
[code language=“php”] function myFunction(?int $number): ?int { if ($number == null) { return null; } return $number * $number; } [/code]
You can now specify that a function cannot return a value. For example:
[code language=“php”] function voidReturn(): void { return 5; } [/code]
This would now return that a void function must not return a value.
If your website software/application supports PHP 7.1 we suggest giving it a try. Our PHP Selector makes it easy to switch between PHP versions so you can revert back to an older version at any time. We hope you all find this to be a useful release!