- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I could have told you that.
In fact... I did tell you that. It's even one of my highest upvoted answers on StackOverflow.
Admin
No repro
But TRWTF is your database.
I agree with your selection of terms here :smile:
Admin
Fix your quoting
Admin
Well I'll be :wtf: I'd actually assumed
or
would evaluate to the first non-falsy value. Instead it evaluates to a boolean like||
. Useless fucking operator. No wonder I'd never used it. Hey, now I remember how I tried doingand that didn't work because $connection was some shitty boolean. So I promptly forgot about
or
in my PHP vocabulary.Whoops, that always gets me :fearful:
Admin
Then pick the one you prefer and only use that, I guess.
Admin
Wait.. it should work here?! Anyway, that's why I don't use it, confuses me everytime.
Admin
There are already enough posts that reading them all has exceeded my patience threshold, so someone may already have mentioned this, but what the heck...
You're all blithering about operator precedence when it is quite clear from the article that the problem is not operator precedence but order of operation.
Or maybe the article is even more :wtf: than PHP, and the writer is even more :wtf: than the article, seeing has how he doesn't know it's called operator precedence...
Admin
Because you're an asshole. Or an idiot. Or both.
Admin
I bet you're not even surprised!
Admin
I could do that, but then I'd have PHP on me.
Admin
I've been using both Perl and PHP for over 10 years and have never used
or
in PHP. But it's common in Perl:my $fh = doSomething or die;
. I thinkor
is a bit of a wart (especially in PHP) and should be ignored and never used. Use||
which every other language uses!Admin
Hmm.
:tropical_drink:
Admin
3v4l.org should be your site of choice for demonstrating PHP wtfery. You submit code, they run it on every version.
http://3v4l.org/SHm0H
Admin
http://3v4l.org/SHm0H/perf#tabs
[image]that's an interesting trend for performance as you get to more and more recent versions of PHP
Admin
Woah, yeah... Most programming languages get FASTER as they age.
At least, all the ones I can think about right now.
Admin
most languages aren't PHP.
Admin
A rant on the design of PHP? What is this, 2005?
PHP 'or' is not the Python 'or', period. It sounds like you're trying to make a case that it's a good idea to ever use a keyword from another language without having a clue what it means in the one in front of you. Stick to the C-style || or just pretend PHP never happened.
Admin
With most things it's best to remain ignorant if at all possible, I agree. PHP is in that category.
Admin
This is from Perl which also has the || and or operators.
Admin
Get rid of those unnecessary parentheses on the shift!
Admin
I am disappointed. I was expecting an article pointing out stupid code. Not a stupid language.
Admin
Well, no contest. Actually in Perl they are useful because
Ok, I realise I'm railing against the fact that in PHP
||
evaluates to boolean. Thator
does so too is actually just consistent which is what @TheCPUWizard was getting at. I'll shut up now about this downgrade of a language.Admin
I really don't understand all the hatred for PHP. It is a widely used language and many sites are implemented using PHP. PHP is a stupid language only if the developer is an idiot.
Admin
PHP is also a fantastic idiot-developer-enabler -- instead of barfing on bad code, it plods on, blithely appearing to work while leaving the next dev a landmine to untangle.
Admin
That is an understatement. The latest stats show that 81.9% of websites are coded using PHP, while the "perfect language" ASP.NET is used only on 16.9%
I've been using PHP for about 15 years, so I've seen my share of WTF. But you can make perfectly fine code in PHP if you know what you're doing.
Admin
Then we may as well write all our code in Shakespeare and Piet.
Some languages are easier to get things right in, and are better as a result. Just because you've seen a working program written in Malbolge does not mean that it is a good language.
Admin
Admin
Has anyone actually done that aside from the guy who used genetic algorithms or whatever to evolve Hello World?
Admin
Someone wrote 99 bottles in it apparently. But no, it's an awful language. Like php.
Admin
A site full of pedants doesn't twig to the misspelling of "truly"?
Admin
Yeah, yeah, I know it's supposed to be a joke, but it's too--you know--subtle. Spell it "true-ly," is my advice.