The conditional operator has higher precedence than the assignment operator, so
$c?$x='TRUE':$y='FALSE'
is the same as
($c?$x='TRUE':$y)='FALSE'
The addition operator has higher precedence than the conditional operator, so
$c?$x+2:$y+3
is the same as
$c?$x+2:($y+3)
If you want to do assignments, use if or add parens. Think of as the conditional operator as an operator that returns something.
In reply to Re^5: Conditional Operator Confusion
by ikegami
in thread Conditional Operator Confusion
by Melly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |