PHP 7.1 Available on all servers. What's new with it?

Written by Trifo 0 Comments

We are happy to announce that we now support PHP 7.1 on our shared, reseller and performance hosting accounts!

We're always keen to bring you the latest new features as soon as possible, and we're pleased to announce that the first 'point' release in the PHP7 series is now here - coming a year after the long awaited PHP 7 release.


PHP 7.1 brings many new features and performance improvements, such as:
  • Nullable types - types can now be made nullable by using a question mark to prefix a type to denote it as nullable.
Example:
function say(?string $msg) {
if ($msg) {
echo $msg;
}
}
 
say('hello'); // ok -- prints hello
say(null); // ok -- does not print
say(); // error -- missing parameter
say(new stdclass); //error -- bad type

  • Void return type - functions declared with void as their return type can either use an empty return value or not return any value:
function should_return_nothing(): void {
return 1; // Fatal error: A void function must not return a value
}


function foo(iterable $iterable) {
foreach ($iterable as $value) {
// ...
}
}

class Page
{
protected const PUBLISHED = 1;
protected const DRAFT = 2;
protected const DELETED = 3;

// ...
}

Square bracket syntax for list() and the ability to specify keys in list(), Catching multiple exceptions types and many more features and changes, available here.

You can switch to PHP 7.1 from your cPanel web hosting control panel Advanced PHP Version Management:

php7-1save

Please note that as of 10th of December 2016, not all CMS, such as WordPress, Joomla and Magento support PHP 7.1 so you should do an in-depth test if you want to use that on a live web site.

Have any questions? Feel free to contact us!

You might also like...

About the Author

Trifo works in customer support at Kualo. He's a ninja at working with popular open source applications like WordPress, Joomla and Drupal to name a few. Fun fact, Trifo recently became a father!