PHP NULL Coalescing Operator
The NULL coalescing operator (??) newly added in PHP 7 is a shortcut for the ternary operation that performs an isset() check.
The NULL coalescing operator checks whether a variable exists and its value is not NULL; if so, it returns its own value, otherwise it returns its second operand.
Previously we wrote the ternary operator like this:
$site = isset($_GET['site']) ? $_GET['site'] : 'Runoob Tutorial';
Now we can write it directly like this:
$site = $_GET['site'] ?? 'Runoob Tutorial';
Example
The output of the above program is:
Runoob Tutorial
Runoob Tutorial
Runoob Tutorial
PHP 7 New Features