Wednesday, 21 April 2021

PHP 7 double question mark ??

 It's the "null coalescing operator", added in php 7.0. The definition of how it works is:

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

So it's actually just isset() in a handy operator.

Those two are equivalent1:

$foo = $bar ?? 'something';
$foo = isset($bar) ? $bar : 'something';


https://stackoverflow.com/questions/53610622/what-does-double-question-mark-operator-mean-in-php

No comments:

Post a Comment