- 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 guess there's no more elegant way to do this (assuming "elegant" means with the least possible amount of characters). My second (or third) assumption is that there's also no more obfuscated way to do this.
[repost: bah, didn't click "quote". Also, boozed]
Admin
Clearly you have never worked with girl programmers!
Admin
FTFY. (mysql_escape_string and mysql_real_escape_string are both MySQL API functions. PHP did not invent these names)
Admin
Once again this proves why lazy developers are the best. Any lazy developer would first google for an existing library function that does what he wants before rolling his own.
Ok I admit in this case common sense would have been enough too as the problem is so general and must so obviously occur all the time that any non-moron would know such a function must exists.
But php is to blame too because if functions were actual methods or at least named in a consistent and sane way, IDE autocomplete would probably make a google search unnecessary.
Admin
Gender has to do with a lot. Men and women think differently. How they approach problems is different. Whether that means men or women produce better code is up for debate, because I think as long as the code functions well, is logical, and is maintainable by the group working on it, you're doing it right. Interestingly enough, most of the women I met that were programmers were distinguishable from the average woman in how they thought. They thought more like men. Don't confuse a rainbow of personality amongst the genders as a lack of distinction.
To say that there's no difference between genders is intellectual deceit. You can't eliminate the physical and mental differences just by believing they aren't there hard enough, even if that's what modern secular humanism teaches.
The big thing here, is that there are significantly less women in the programming profession, and it's not because there is some barrier to entry, it's just a lack of preference in women to be employed as a programmer. So it IS a significant event to see a woman programmer.
Just as you shouldn't assume a woman programmer is inferior, you shouldn't assume all women are capable programmers.
Admin
I have. MOst of thenwere good - if anything a slightly higher percentage than male programmers. However the sample size is small.
Admin
In my experience, code like this isn't written, it grows. Someone tried something. Maybe it worked and later was modified. And modified. And modified. Perhaps by "the new guy" - someone different each time who was too scared to change much (if it ain't broke, don't fix it). Or maybe it didn't work and they kept trying stuff until it did. Whatever the reason, I'm sure this isn't how it started out.
Admin
And that is why you always RTFM.
Admin
Not enterprisey enough.
Admin
Admin
Definitely PHP
Admin
Extra WTF points for the `broken' spacebar.
Admin
Admin
That's "elegant"?
Admin
Join and split are both functions not found in every programming language, they are in some but not all. When the article is directly referencing PHP code in it, it's fairly safe to assume it's talking about PHP. Unless you're an idiot or something.
Admin
compare this to the PHP-equivalent:
Admin
Now imagine a world without Perl. The same thing would probably look like this:
Any better? ;-)
Admin
Disclaimer: I do not condone PHP. I am just explaining this.
If you have an array called $letters, and it contains this:
Then when you do:
Basically $k is the "key", which is the index. And $v is the "value", which is the actual contents of the array at that index.
You don't have to do a foreach like that. If you don't care about the index and just want to walk the array like most languages, you can do this:
Admin
I can't believe no one posted the shortest (and therefore most cryptic) way to do this in Perl yet:
$name =~ s.\W._.g;
Admin
And yet people still use the old MySQL extensions. One of the reasons I have low opinions of many (not all) web based developers is that the term "parameterized queries" is an enigma to them. Even when you point out that PDO exists (in the case of a PHP developer) they just shrug and say "we always did it this way".
That and I'm a snobby pretentious git.
Admin
See the first page ...
Admin
Admin
I dispute that.
If you are reading TDWTF you are probably smarter than 90% of the other 'programmers' out there.
However, this may not mean you are a 'super programmer', just that 90% of the programmers out there are even crapper than you are.
Admin
Someone misses streams.
Admin
Yeah http://dev.mysql.com/doc/refman/5.0/en/mysql-escape-string.html
This function is always pointed as a PHP failing but it is actually what the underlying library says. PHP does get a lot of flack for being a thin wrapper around a lot of libraries though...
Admin
I think . is a little shorter than /
Admin
when you do a foreach ( $array as $key => val )
the $key var assumes the index of the array and the $val var assumes it's value so for instance
$array = array("foo" => "bar", 12 => true); foreach ( $array as $key => val ) { echo $key . ' ' . $val . ' '; }
returns "foo bar 12 true"
Admin
Your Captcha reads to me as "No Bi's"...homophobic Captcha's unite! :)
Captcha: DUIS (Driving under the influence, multiple times)
Admin
So many comments and no one assumed he's working around unicode multibyte characters.
PHP has no native unicode string but mbstring extension replaces SOME functions with utf8 aware. As far as I remember, indexing brackets[] still return bytes, not unicode characters (multibyte). So to retrieve a single character you really have to do substr (which handles multibyte fine).