Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PHP 7 null coalesce operator
* Null coalesce operator
$array = ['foo'=>'bar'];
//PHP5 style
$message = isset($array['foo']) ? $array['foo'] : 'not set';
echo $message.PHP_EOL;
//PHP7 style
$message = $array['foo'] ?? 'not set';
echo $message.PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.