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.
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
}
- Iterable pseudo-type - a new pseudo-type (similar to callable) has been added.
function foo(iterable $iterable) {
foreach ($iterable as $value) {
// ...
}
}
- Class constant visiblity modifiers - small but essential change in the Object Oriented Programming, that enforces encapsulation.
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:
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!