Location: PHPKode > scripts > Body Mass Index Calculator > body-mass-index-calculator/example.php
<?php
require("bmi.class.php");

$bmi = new bmi();
$tmp = $bmi->calculate(66, 1.67);
echo "Your BMI is:", $tmp, "<br />";
$tmp2 = $bmi->translate($bmi->check($tmp));
echo "This is considered as ", $tmp2;

# Or, if you want to build your own parser for the bmi::check() result;

function parse_check($c) {
	$c = intval($c);
	switch($c) {
		case 1:
			return "<strong>You're severely underweight, consider visiting a doctor.</strong>";
		case 2:
			return "<strong>You're underweight.</strong>";
		case 3:
			return "<strong>You're normal (what that's supposed to mean).</strong>";
		case 4:
			return "<strong>You're overweight.</strong>";
		case 5:
			return "<strong>You're slightly obese.</strong>";
		case 6:
			return "<strong>You're obese.</strong>";
		case 7:
			return "<strong>You're really obese.</strong>";
		default:
			return "Error";
	}
}

echo "<br />Or you can put it like this: ", parse_check($bmi->check($tmp));
?>
Return current item: Body Mass Index Calculator