Posted February 16, 2017 by Simon
Back in September of last year we posted about the new features and speed improvements that came with PHP 7. In this post we will be looking at some of the improvements and additions to PHP in the latest version, PHP 7.1.
This is a feature that is already well supported in languages such as Java and C#, and it is now available in PHP. This feature allows you to return null from a function.
This function has been a much requested and waited for feature, and is now included with PHP 7.1. Functions can now set the return type to void.
Symmetric Array Destructuring
Arrays can be destructured for assignment using the array syntax (). The list() syntax is still available, but this is a great alternative to that solution.
Class Constant Visibility
Access modifiers with a constant variable can now be used inside a class, which allows you to manage its visibility across your project.
This is a new pseudo-type that PHP 7.1 has introduced, that is comparable to callable. It returns type when used in parameter, and accepts objects or arrays that use the traversable interface.
Multi Catch Exception Handling
This allows you to catch one or more exceptions at a time from a single catch.
Support for Keys In list()
Keys can now be specified while a list is created using either the list() function or the new shorthand syntax, such as () that we mentioned earlier.
Support for Negative String Offsets
Negative offsets can now be employed for string manipulation, and simple variable parsing syntax can be used inside a string.
Convert Callables to Closures
Within the Closure class PHP 7.1 adds a new static method Closure::fromCallable() which converts callables to Closure objects.
Asynchronous Signal Handling
The new pcntl_async_signals() function has been added which directly enables asynchronous signal handling. This new function also reduces overhead using ticks.
HTTP/2 server push support in ext/curl
HTTP/2 push can now be used using ext/curl. The following new constants have been added for curl_multi_setopt() in PHP7.1:
This is just a summary of some of the major updates and changes in PHP 7.1, you can read more and see code examples of the new features on the PHP web site here. If you would like to discuss your requirements or you have any other questions, then please get in touch.