The first line is parsed like so:
$out = ($a > 9 && $a < 15 ? "option1" : $a < 5) ? "option2" : "option3";
Which is equivalent to the following (when $a == 11
):
$out = "option1" ? "option2" : "option3";
"option1"
coerced to boolean is true
, so the above evaluates to "option2"
.
The second is being parsed as you would expect:
$out = ($a > 9 && $a < 15) ? "option1" : ($a < 5 ? "option2" : "option3");