Blog

The Null Coalesce Operator '??' has been introduced in PHP 7.

It returns its first operand if it exists and is not NULL; otherwise it returns its second operand.

PHP 5

$name = isset($_GET['name']) ? $_GET['name'] : 'nobody';

PHP 5.3 (elvis operator)

$name = $_GET['name'] ?: 'nobody';

PHP 7 (null coalescing operator)

$name = $_GET['name'] ?? 'nobody';
Zoeken