When David was approached by a colleague for an estimate on some PHP work, David insisted that he'd need to see some of the code first. The only background David had on the project was that it was a PHP site with a MySQL backend, and a pretty sizable user base.

When David received the code, the first thing that he noticed was an unreasonably large file called namelib.php. It was apparently intended to clean up users' first names...

<?
$name = $_GET['name'];
switch($name)
{
	case "aafke":
		echo "Aafke";
		break;
	case "aaron":
		echo "Aaron";
		break;
	case "abbie":
		echo "Abbie";
		break;
	case "abby":
		echo "Abby";
		break;
	case "abdel":
		echo "Abdel";
		break;
	case "abe":
		echo "Abe";
		break;
	case "abeltje":
		echo "Abeltje";
		break;

	/* Snip */

	case "zora":
		echo "Zora";
		break;
	case "zorah":
		echo "Zorah";
		break;
	case "zuzana":
		echo "Zuzana";
		break;
	case "zuzanna":
		echo "Zuzanna";
		break;
	case "zuzanny":
		echo "Zuzanny";
		break;
	default:
		echo $name;
// Name not in the database yet, lowercase is better than nothing } ?>

David couldn't help but smile as he replaced thousands of lines of generated code with one easy line:

echo ucfirst($_GET['name']);
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!