4

What is the difference between null coalesce operator and elvis?

$a = null;

echo $a ?: 'default1';

echo $a ?? 'default2';

It looks to me as they are doing the same job. However there must be difference. :)

Can someone point it out for me?

Akash lal
  • 302
  • 5
  • 18
Jan Tajovsky
  • 1,132
  • 2
  • 13
  • 31

0 Answers0