How can I understand nested ?: operators in PHP? [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Problem with PHP ternary operator I was reading up a bit on PHP in this article, and I stopped for a while to consider one of his gripes. I can't figure out how on earth PHP comes to the result that it does. Unlike (literally!) every other language with a similar operator, ?: is left associative. So this: $arg = 'T'; $vehicle = ( ( $arg == 'B' ) ? 'bus' : ( $arg == 'A' ) ? 'airplane' : ( $arg == 'T' ) ? 'train'