-
Website
http://www.prodevtips.com -
Original page
http://www.prodevtips.com/2008/02/25/the-worst-php-code-in-the-world/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
ellisgl
1 comment · 2 points
-
davidzurich
1 comment · 1 points
-
brittney08
1 comment · 1 points
-
wwfa
1 comment · 1 points
-
SwellJoe
1 comment · 3 points
-
-
Popular Threads
Thats so pretty...my favorite is:
// Please do not touch my code.
to which my answer would be:
thank you
;) But looking back, i got loads of old code thats not too pretty, probably those guys improved too.
Love
I found this snippet , pretty funny, i still try figure why to use this code when he could use pure html...
<?php
// DYNAMIC Product list for my products.!
// Based on the General Publci Liesencec!!!!!!!!!!!!!!!!
// Please do not touch my code.
echo "";
echo "";
// DYNAMIC ARRAY OF MY TABLE HEADERS
$array[0][key] = 0;
$array[0][Value] = Price;
$array[1][key] = 1;
$array[1][Value] = ID;
$array[2][key] = 2;
$array[2][Value] = Name;
$array[3][key] = 3;
$array[3][Value] = Type;
$array[4][key] = 4;
$array[4][Value] = Description;
$array[5][key] = 5;
$array[5][Value] = Weight;
$array[6][key] = 6;
$array[6][Value] = Code;
$array[7][key] = 7;
$array[7][Value] = Product;
$array[8][key] = 8;
$array[8][Value] = MoneyCurrency;
$array[9][key] = 9;
$array[9][Value] = Paymentmethod;
$array[10][key] = 10;
$array[10][Value] = PayPal;
if ($array[10][Value] == PayPal){
function addPayPal(){
return "PAYPAL OK";
}
}
echo "
(ID: $array[0][key])-$array[0][value]
(ID: $array[1][key])-$array[1][value]
(ID: $array[2][key])-$array[2][value]
(ID: $array[3][key])-$array[3][value]
(ID: $array[4][key])-$array[4][value]
(ID: $array[5][key])-$array[5][value]
(ID: $array[6][key])-$array[6][value]
(ID: $array[7][key])-$array[7][value]
(ID: $array[8][key])-$array[8][value]
(ID: $array[9][key])-$array[9][value]
(ID: $array[10][key])-$array[10][value]
";
/*
TODO: Put in the list of items here in table tags
*/
echo "";
echo "";
?>
if($controlip == ""){
echo"Sie ?bertragen an unser System keine IP-Adresse und haben damit leider nicht die Rechte sich diese Seiten anzusehen!";
}else{
function func_header($text = "")
{
echo "$text";
}
if($goon == "logout")
{
$ask= "UPDATE `adminuser` SET logintime=logintime-3600 WHERE `adminuser`='$adminuser'";
$result = mysql_query($ask) or die(mysql_error());
The function really got to me..............lmfao.............
thanks for this man........loved it.....
* styles all embedded in html. really no CSS whatsoever
* queries embedded directly in pages, copy-pasted to multiple places
Add in:
* the site uses frames. extensively :(
* payments, for instance, were reimplemented in a dozen or so places using copy-paste. bugs were often fixed in only one place, or fixed in different ways in different places.
The worst though - there were no 'echo' statements for printing HTML. The previous developers figured out echo statements were bad. Now hear what their solution was:
For every echo statement, they moved the html into a text .inc file and included it from the php page. These .inc files were strictly HTML only, and named with seemingly random abbrevations, eg. index_a.inc, index_qp.inc, index_lj.inc.
You may be wondering, "How did they handle things like looped HTML tables?"
By putting every line in its own file. There was a .inc file for the begin table tag. A separate file for the end table tag. A separate file for the TR begin tag, and a separate file for the TR end tag. Another file for each TD that had to be looped on. Rinse and repeat for every single page in this rather large website.
And this is now the my "baby" along with the rest of the dev team. Most of our time is taken up with maintenance and bugfixes, and projects require hard decisions on how much to rewrite. That's a very hard decision - Do we have time to rewrite X, or do we need to continue implementing some of this new project using X, which is horrendous and horribly broken?
choose life drop the if :)
K: I have seen OS Commerce and it doesn't put it to shame but it's not pretty either that I can agree with you on!
Then they need our companies to support such code -- We dislike bad code too but we work on it for money. $20 hourly.
www.kauroff.com
I mean the equivalent in the "real world" would be if for instance a plumber installs a lot of piping in your house and it all works to begin with. After awhile though all hell breaks loose and your house ends up flooded. It's nothing less than a scam that you can sue for. And this should not be any different.
I feel for you guys. It makes me glad I get to go back over some of my awful coding mistakes on routine code rewrite cycles!
The issue is there's no minimum barrier of entry for PHP - anyone can use it, including noobs. It doesn't punish you for bad coding habits, like - say - java.
Thanks for sharing this. You made me feel much better about the 'bad smells' in my own code =)
Jan
Probably made by someone's nephew
lol
Working with someone elses code is a nightmare, especially if they really havent got a clue. I assume this was a true story? If so what size where the DB date and click logs, lol.
I especially like the end and those immortal words....
"I need a Chang, a big one" - usually helps.
Though mine is messy and bad, it still works fine, but not as messy as that above. That just takes the p...
And they tell everyone they know PHP!! Its sad but true. I'm going to start a site where we can blacklist these what I like to call "Cowboy Programmers" (YEEEHAAA!!!! Lets build a system in PHP!!! YEEEHAAA!!!) because they soil the job market and ruin companies with great ideas forever.
Also have worked on lots of projects with comments like:
//Must put search results here
- with no further code to search any database - What a joke!!
This is the type of stuff I used to see in "sites" built by "programmers" using ASP and Access!! ROFL!!
I started coding when I was 11. I taught myself from books (GW Basic). I can not relate to you guys who say your code used to look like that, sorry. So I'll just say I have never done anything so idiotic. Its just easier to write an HTML site than to try and work with that drivel!!
The best part is how surprised the poor site owner seems to be. LMFAO!! "Really?" - Yes. You got screwed, man! Sorry to be the bearer of bad news!