Ben sent in the following snippet from a PHP site. His description of the site as a whole is unpublishable in most countries, but among his frankly shocking profanity he pointed out a lack of error checking and comments, and an abundance of unreadable inline code and confusing, unnecessary functions.
When Ben tried to describe the following routine though, he broke down, weeping openly. While we wait for him to regain his composure, let's ponder the depth of wrong present in this code:
<style type="text/css">
.file_1
{
height:26px;
float:left;
background:url(../images/input2.png) left top no-repeat;
width:188px;
border:0px solid #A7A9AC;
font-family:Arial; font-size:12px; color:#4a4a4a; font-weight:normal; text-align:left;
}
<?php
for($i=0;$i<count($FileClassArr);$i++)
{
?>
.<?php echo $FileCLassArr[$i]?>
{
height:26px;
float:left;
background:url(../images/input2.png) left top no-repeat;
width:188px;
border:0px solid #A7A9AC;
font-family:Arial; font-size:12px; color:#4a4a4a; font-weight:normal; text-align:left;
}
<?php
}
?>
</style>
That's right, every file gets its own CSS class. And, just so none of the files get jealous of each other's classy style, they're all exactly the same! Why wouldn't you just define one class and apply it to every file's HTML element? We'd ask Ben if he discovered the original developer's rationale, but we don't want to set him off crying again.
There, there, Ben. We're misting up a little bit on your behalf.