Stephen R. Blair

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 for this entry

Leave a Reply

You must be logged in to post a comment.

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!