3 ms·
While we are discussing PHP, why is the ternary operator nesting behavior different from every other mainstream language using "?" and ":" ?
by niggler 14y ago
While we are discussing PHP, why is the ternary operator nesting behavior different from every other mainstream language using "?" and ":" ?
- deleted 14y ago[deleted]
- mscarborough 14y agoI'm not sure, but probably historical reasons like much else in PHP. Though, I'm not a real fan of reading other people's nested ternary ops, because if you're going that deep, just write an if/then in whatever language you're using? It will keep you under 80 chars which is a polite way to go.
- leeoniya 14y agothere's a lot of stuff in PHP that bothers me...mostly consistency of function arg orders and function naming. but this has to be the one that really drives me up the wall. i cannot believe they choose to maintain this broken implementation because it's defined improperly in the spec. just yuck.
- duskwuff 14y agoPresumably: Rasmus got the precedence wrong when he wrote the parser, and it's way too late to fix it now.