Basically interpreter evaluates this expression from left to right, so:
echo $test == 'one' ? 'one' : $test == 'two' ? 'two' : 'three';
is interpreted as
echo ($test == 'one' ? 'one' : $test == 'two') ? 'two' : 'three';
And the expression in paratheses evaluates to true, since both 'one' and 'two' are not null/o/other form of false.
So if it would look like:
echo $test == 'one' ? FALSE : $test == 'two' ? 'two' : 'three';
It would print three. To make it work okay, you should forget about combining ternary operators, and use regular ifs/switch for more complicated logic, or at least use the brackets, for the interpreter to understand your logic, and not perform checking in standard LTR way:
echo $test == 'one' ? 'one' : ($test == 'two' ? 'two' : ($test == 'three' ? 'three' : 'four'));
//etc... It's not the most understandable code...
//You better use:
if($test == 'one')
echo 'one';
else { //or elseif()
...
}
//Or:
switch($test) {
case 'one':
echo 'one';
break;
case 'two':
echo 'two';
break;
//and so on...
}