To be fair: If you are chaining ternary expressions, you deserve to suffer whatever pain the language happens to inflict upon you tenfold.
Why?
It’s perfectly readable.
It is sort of readable. A switch is “perfectly” readable for switching.
Ternary expressions aren’t switches though
Which is exactly why you shouldn’t be using them in a situation that clearly calls for a switch.
[This comment has been deleted by an automated system]
The fault is the programmer for not using a switch statement.
Sure, it’s counterintuitive, but so is not bracketing things in ternary operations.
You know that programmers of other languages don’t have to find excuses for their tool constantly, right?
You don’t know many languages, huh?
Hating on php is one of the reasons i left reddit. This is just people who don’t use php hating php for some reason. You can do dumb examples like this for any language. Low effort and funny for children.
Your feelings are valid. I wonder though, would you put up this level of defense for posts making fun of arbitrary parts of non PHP languages?
You are not your favorite language. And I find most criticisms of most languages to be very valid. I don’t think the intent of OP is to insult all PHP programmers. It’s okay to like a language that has problems. All languages do.
I’d wager prevalence is part of their problem. Jokes get tired after a while, but that doesn’t always mean they stop.
PHP, like any language, has its problems, but it seems to get poked at a lot more often. But making the same joke over and over has been a problem long before reddit was a thing.
Now do CGI.
Please. I worked with it for five years and I still don’t understand it.
I get hating on PHP is a meme, and the language certainly has faults, but I feel like it’s no more arbitrary than how JavaScript behaves. And just like JavaScript, if you follow modern standards and use a modern version, it’s a much better experience. The language is only as good as the programmer.
but I feel like it’s no more arbitrary than how JavaScript behaves
This is not the flex you think it is.
Finally got it…
$a == 1 ? "one" : ( ( $a == 2 ? "two" : $a == 3 ) ? "three" : "other" )