|
|
|
| Hurry! Enter The Daily WTF's OMGWTF2 Contest by June 28th! - Prizes! Fame! Trophies! Do your worst: http://omg2.thedailywtf.com/ |
| « Ask WTF: Salary | Best of Email: Career Limiting Email, That's What the BCC Field is for, and More » |
Juho was skimming around code, searching for a bug, when saw the following PHP code. In my opinion, its purpose was probably as a workaround for a bug in MySQL 5.0. I mean, I hope it was.
At least the original author knew it was bad code.
<?php /**Extremely retarded replace for getting rid of entities of scandinavian characters => text searches won't work.. * * See you @ www.thedailywtf.com */ $entities_to_replace=array("ä", "ö", "å", "Ä", "Ö", "Å"); $clean_values = array(chr(228), chr(246), chr(229), chr(196), chr(214), chr(197)); $field_db_value = str_replace($entities_to_replace, $clean_values, $field_db_value); ?>
Re: Known Bad Code
2012-10-03 08:19
•
by
phihag
(unregistered)
|
$convmap = array(0x80, 0xffff, 0, 0xffff); Taken from a stackoverflow answer by yours truly. |
Left out half of the Scandinavian languages
2012-10-03 09:13
•
by
Kasper
(unregistered)
|
|
TRWTF is that he left out Æ and Ø. That means he has got Swedish and Finnish covered, but not Danish and Norwegian.
I am curious what str_replace must look like in order for this to work in the first place. |
Dont worry I will create some stupid code and name one of the variables theDailyWTF. |
| « Ask WTF: Salary | Best of Email: Career Limiting Email, That's What the BCC Field is for, and More » |