Skip navigation.
Home

archives

if, if, if, if, else, else, else, else...*sob*

DB Hoopla | Fugly Code

Most of the WTF's I post here are submitted from the readers. Today I give you one from the code I have to maintain. In fact, I started The PHP WTF because of this code base. There are 'jewels' like today's example scattered all over the place. Today's example shone so brightly that I had to share it.

Curly braces are optional for simple IF/ELSE statements in PHP but there is a fine line between clear, concise code and a WTF. Today's code is perfectly valid but you'll probably stare at it trying to match the ELSE statements to the IF statements. I think this is what happens when your brain is screwed in backwards and you haven't learned about ELSEIF yet...