Stephen R. Blair

A PHP Life

PHP Perfect Shower

by Stephen Blair on Jun.17, 2009, under A PHP Life

If your shower knew PHP, you would have a perfect shower every time!


// PHP Perfect Shower | Stephen R. Blair | www.srblair.com

require_once('water_control.php');

// Run the hot water if it is not already running
if(!isset($hotWater)) {

	$hotWater = true;
	hotWaterTemp(); //Get the hot water temperature

}
// Run the cold water if it is not already running
if(!isset($coldWater)) {

	$coldWater = true;
	coldWaterTemp(); //Get the cold water temperature
}

$targetWaterTemp = '107'; // Your ideal water temperature in degrees

$currentWaterTemp = $hotWaterTemp - $coldWaterTemp; // The current water temperature

// Adjust the hot and cold water until desired temperature is met
while($currentWaterTemp != $targetWaterTemp) {

	if($currentWaterTemp > $targetWaterTemp) {

		moreColdWater(); // Add cold water if it is too hot

	} else

	if($currentWaterTemp < $targetWaterTemp) {

		moreHotWater(); // Add hot water if it is too cold

	}

}

1 Comment :, , , , , more...

Waking Up PHP

by Stephen Blair on Apr.25, 2009, under A PHP Life

My PHP Coffee Mug script has inspired a new category on my blog called A PHP Life and here is the latest addition!

Stay tuned for more to come!



// Waking Up PHP | Stephen R. Blair | www.srblair.com

function morningAlarm() {

	//The snooze button has not been smashed yet
	$snoozeCount = 0;

	//The alarm is buzzing
	if(isset($alarm)) { 

		if($snoozeCount <= 3) { //If you have not hit the snooze button at least 3 times...

			$snoozeCount++; //Go ahead and hit it again!

		} else { 

			$wakeUp = true; //Otherwise, wake your ass up!

		}

	}

}

Leave a Comment :, , , , , , , , , more...

PHP Coffee Mug v1.0

by Stephen Blair on Apr.24, 2009, under A PHP Life

A co-worker and myself went to Starbucks today where I decided that I really could use an office coffee mug to keep at work. I of course chose the largest mug they had which also just happens to come with a porcelain pen that you can use to write on it and eventually heat treat to make permanent. As I was sitting here writing code for work I was also thinking about what clever sayings or cool pictures I could put on my new coffee mug. The mixture of work and play came out as a random coffee mug php script I have come to label as “PHP Coffee Mug v1.0″.

I hope you enjoy my random and utterly useless coffee mug script!


// PHP Coffee Mug v1.0 | Stephen R. Blair | www.srblair.com 

require_once('coffee_cup.php');

if($coffeeCup == empty) {

	//Check to see if there is a fresh pot of coffee
	if($coffeePot != 'fresh') {

		//Make a fresh pot of coffee
		makeCoffee();

	} else {

		//Pour coffee into the coffee cup
		pourCoffee();

		//Drink the coffee!
		drinkCoffee();

	}

} else {

	//Check the date for the coffee in the mug
	if($date > $dateExpire) {

		//Rinse out the cup if it is old coffee
		rinseCup();

		//Check to see if there is a fresh pot of coffee
		if($coffeePot != 'fresh') {

			//Make a fresh pot of coffee
			makeCoffee();

		} else {

			//Pour coffee into the coffee cup
			pourCoffee();

		}

	} else {

		//The coffee is fine, drink it!
		drinkCoffee();

	}

}


Leave a Comment :, , , , , , , , , , , , , , , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!