Month archive for November, 2011 1 posts

A Love Poem in PHP

Posted by jeremyclarke on November 7, 2011 · General · WordPress

Wrote this a long time ago but never posted it. Stumbled onto it while cleaning up my email:

<?php
	$me = new Lover;

	$me->partner = $you;

	$me->feelings = array('adore','miss','want','love');

	foreach ($feelings as $feeling) {

		$me->express_feeling($feeling);

		if ($you->feeling_mutual($feeling))
			$me->epic_hugs($you);
	}
?>

Sure, it’s not the most expressive form of writing out there, but like with Haiku I think the limitation and challenge of putting poetry into code form can help push you to create something really fresh and strange without the baggage and cliché feel of regular poetry. I also just love naming variables and methods ;)

Either way, I think my poem is at least more uplifting than this other PHP love poem I found.

It was actually a follow-up to a shorter, twitter-length PHP love poem I wrote around the same time:

<?php
	$things_i_dont_miss_about_you = array();
?>

Submit your coded love poems in the comments, bonus points if it could at least theoretically execute in real life (assuming for example things like the existence of a “Lover” class with an express_feeling() method). If you’ve got the time write us an Epic PHP Poem, including all the needed class definitions :P