Oops, no-perator found. Have a joke instead.
arithmetic
bitwise
null coalescing
$a ?? $b
Null coalescing operator
Return the left variable if it's set and not null, otherwise return the right value.
Tags
$name = null;
'Hey, ' . ($name ?? 'buddy'); // "Hey, buddy"
// "Hey, Cassian!"
$name = 'Cassian';
'Hey, ' . ($name ?? 'buddy'); // "Hey, Cassian"
comparison
logical
strings
What is this? Who are you!?
PHP Operators is a reference guide for operators old and new in the PHP programming language. We're SPATIE, a web development agency from Belgium. Besides client work we like to contribute to the open source community and make fun projects like this one.