Saw this question on Toptal and got a little confused:
$v = 1;
$m = 2;
$l = 3;
if ($l > $m > $v) {
echo "yes";
}
else {
echo "no";
}
I get why the answer is "no", but their reasoning was a bit confusing to me:
First,
$l > $m
will be evaluated which yields a boolean value of1
ortrue
. Comparing that boolean value to the integer value 1 (i.e.,bool(1) > $v
) will result inNULL
, so the output will be “no”.
Why does bool(1) > $v
become null
and not undefined
or false
?