4 ms·
That's where the coalesce operator ("??") is for. Exactly to suppress the warning and avoid verbose isset() calls: echo $foo['a']['b'] ?? 'default_value';
by juriansluiman 11y ago
That's where the coalesce operator ("??") is for. Exactly to suppress the warning and avoid verbose isset() calls:
echo $foo['a']['b'] ?? 'default_value';
- Udo 11y agoI'm looking forward to this in PHP7. My current workaround, which exists for the same reason as the coalesce operator (https://wiki.php.net/rfc/isset_ternary https://wiki.php.net/rfc/isset_ternary) is a custom function: $v = @first($var1, $var2, 'some-default'); which will simply return the first parameter that has a non-null, non-empty-string value.