Hacker News new | ask | show | jobs
by niggler 4843 days ago
While we are discussing PHP, why is the ternary operator nesting behavior different from every other mainstream language using "?" and ":" ?
3 comments

there'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.
I'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.

Presumably: Rasmus got the precedence wrong when he wrote the parser, and it's way too late to fix it now.