The Complete Magazine on Open Source

PHP upgrades to feature nullable types

SHARE
/ 422 0

PHP

The PHP family has been expanded with the arrival of its version 7.1.0. The first point release update in the PHP 7 line comes with nullable types to deliver an advanced development experience.

Nullable types are not new to the programming world. However, this new debut on the version 7.1.0 of PHP finally enables a check type to be of some specific type or null. As per a proposal, type declarations for parameters and return values can be marked as nullable by prefixing the type name with a question mark.

“This signifies that as well as the specified type, null can be passed as an argument or returned as a value, respectively,” the proposal reads.

In addition to the new type declaration, the latest PHP release comes with features such as a void return type and class constant visibility modifiers. The language also gets support for catching multiple exceptions types.

Developers can use square bracket syntax to array destructuring assignment through the advanced PHP release. The programming language now also comes with functions such as session_create_id() and session_gc(). Besides, there is class constant visibility.