Just a flash. Take these (the constructs that don't work)
echo (TRUE ? "a" : FALSE ? "b" : "c")."\n";
echo (TRUE ? "a" : TRUE ? "b" : "c")."\n";
and indent them (as you normally would, if they were actual if{} else{} blocks). You'd get:
// (exaggerated indentation)
echo (TRUE ?
"a" :
FALSE ?
"b" :
"c");
echo (TRUE ?
"a" :
TRUE ?
"b" :
"c");
see how it kinda has a "step-down" look to it?
Invert the conditions (i.e., [font=monospace]!condition[/font]) and switch the order of their (if true) / (if false) expressions. You'll end up indenting out, then indenting back in, like this:
echo ( !TRUE ?
!FALSE ?
"b":
"c":
"a"
);
echo ( !TRUE ?
!TRUE ?
"b":
"c":
"a"
);
equivalent conditions, but it works as expected.
Now, I'm not advocating using deeply nested ternaries everywhere. It's just a thorn in my paw when I can't get something to work that should work, dammit. So, just remember to always put new conditionals first, in the "if true" expression, and never in the "if false".
echo (!TRUE ? !FALSE ? "b" : "c" : "a")."\n";
echo (!TRUE ? !TRUE ? "b" : "c" : "a")."\n";
BTW Merry Christmas, everyone : )