archives
one wtf, two wtf, three wtf...ah ah ah!
Submitted by phrax on Wed, 2004-12-01 10:17. Wonky CodeI had to confirm that this was production code. It's always more funny, or tragic, when production code is bad. Thanks to Søren for sending this in.
What's the most efficient way to skip a few numbers? Well it's not this way! It's bad enough that 2, 3 and 4 are literals and not constants, but they also represent database logic. At least they didn't select *
and skip records with the wrong TypeId's.
About The PHP WTF
Submitted by phrax on Wed, 2004-12-01 23:05.The PHPWTF is dedicated to the uglier side of PHP development. The site is maintained and run by Ben Wong, a PHP programmer from the early days. Like many PHP developers Ben had to suffer with other people's bad PHP code. After years of swearing under his breath and wondering how people can write such bad PHP he decided to share his misery with the rest of the world.
The site was launched in early September 2004 and has been growing steadily. As of November 2004 the site averages 1700 unique vistors a day. The majority of visits come from RSS readers around the world. There is also an unusual amount of PHP WTF's from Germany. Ben doesn't think that means anything other than Germans are less bashful about sharing bad code.
The site began as a B2Evolution blog and has been migrated over to Drupal, a much more flexible content management system.
When a function just won't do...
Submitted by phrax on Wed, 2004-12-01 23:16. Hall of Fame | Bad ArchitectureThanks to Michael for sending this in! He was doing a code audit on a PHP application developed by a contractor. Our story starts with an include file named magdit.inc, which is Dutch for "isthisallowed".
This example makes it into the WTF Hall of Fame because it violates so many good design principles. Take a look at magdit.inc to get you started...