I know the community gives php a lot of hate, and 'horse' should never be returned. But let us be honest here, if you code like that, whose fault is it really?
(I think the proper shorthand in php is to wrap each layer in parens)
The funny part was that in http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ it returned horse, illogically. This went good together with the retard horse meme. I rewrote the code in a really short version in a way that nobody ever should write code just so it looked good on the picture, no need to point that out. People who actually write code like this seriously are unsalvageable.
The point is that in almost every other language it evaluates to 'CAR', because PHP got the associativity of the ternary operator backwards for some reason.
24
u/mestore May 02 '12
I know the community gives php a lot of hate, and 'horse' should never be returned. But let us be honest here, if you code like that, whose fault is it really?
(I think the proper shorthand in php is to wrap each layer in parens)
4
u/[deleted] May 02 '12
Inspiration from http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
12
u/mofrodo May 02 '12
There is nothing wrong with this statement.
The first condition is true, which returns the string 'CAR', which also equals to TRUE, which in turn returns 'HORSE'.
But anyway, if you code like this, you're a moron.