Well, the ? and : have equal precedence, so PHP will parse left to right evaluating each bit in turn:
echo ($test == 'one' ? 'one' : $test == 'two') ? 'two' : 'three';
First $test == 'one'
returns true, so the first parens have value 'one'. Now the second ternary is evaluated like this:
'one' /*returned by first ternary*/ ? 'two' : 'three'
'one' is true (a non-empty string), so 'two' is the final result.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…