3 ms·
I feel like I want to test what happens if you put values like "", false, " ", 0, an empty array, etc etc etc in front of ??. Because, you know, this is PHP.
by AlyssaRowan 12y ago
I feel like I want to test what happens if you put values like "", false, " ", 0, an empty array, etc etc etc in front of ??.
Because, you know, this is PHP.
- itafroma 12y ago> I feel like I want to test what happens if you put values like "", false, " ", 0, an empty array, etc etc etc in front of ??. All of those would result in the variable being assigned those values: the null check uses the same semantics as is_null(), and the truth table for those values is: $v is_null($v) ------------------ '' FALSE false FALSE ' ' FALSE 0 FALSE [] FALSE If you want to all falsy values to use the fallback value, use the shorthand ternary operator (?:) instead.
- raziel2p 12y agoOnly null will return the default value. http://3v4l.org/jphnq http://3v4l.org/jphnq