Update for PHP 7 (thanks to shock_gone_wild )
PHP 7 introduces the so-called zero-coalescence operator, which simplifies the following statements:
$var = $var ?? "default";
Before PHP 7
No, there is no special operator or special syntax for this. However, you can use the ternary operator:
$var = isset($var) ? $var : "default";
Or like this:
isset($var) ?: $var = 'default';
hek2mgl Sep 03 '13 at 23:55 on 2013-09-03 23:55
source share