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
  • 314
  • 6
  • 18
Jan Tajovsky
  • 1,162
  • 2
  • 13
  • 34

0 Answers0