Measurement Conversion


Fahrenheit (Fº): <-----> Celsius (Cº):
Inch (in): <-----> Centimeter (cm):
Feet (ft): <-----> Meter (m):
Mile (ml): <-----> Kilometer (km):
Gallon (gal): <-----> Liter (L):
Ounce (oz): <-----> Gram (g):
Pound (lb): <-----> Kilogram (kg):


getMessage(), "\n"; } ?>

0) { if (!is_numeric($_POST['F'])) throw new Exception('Data entry is not numeric'); $FAsStr = $_POST["F"]; $num = (round($FAsStr * 100.0)) / 100.0; $n = (($num - 32.0) * 5.0) / 9.0; $n = (round($n * 100.0)) / 100.0; return $FAsStr . " F --> " . number_format((float)$n, 2, '.', '') . " C" . "
"; } else return ""; } } function convert_CtoF() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["C"]) > 0) { if (!is_numeric($_POST['C'])) throw new Exception('Data entry is not numeric'); $CAsStr = $_POST["C"]; $num = (round($CAsStr * 100.0)) / 100.0; $n = (($num * 9.0) / 5.0) + 32.0; $n = (round($n * 100.0)) / 100.0; echo $CAsStr . " C --> " . number_format((float)$n, 2, '.', '') . " F" . "
"; } else return ""; } } function convert_intocm() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["in"]) > 0) { if (!is_numeric($_POST['in'])) throw new Exception('Data entry is not numeric'); $inAsStr = $_POST["in"]; $num = (round($inAsStr * 100.0)) / 100.0; $num *= 2.54; $n = (round($num * 100.0)) / 100.0; echo $inAsStr . " in --> " . number_format((float)$n, 2, '.', '') . " cm" . "
"; } else return ""; } } function convert_cmtoin() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["cm"]) > 0) { if (!is_numeric($_POST['cm'])) throw new Exception('Data entry is not numeric'); $cmAsStr = $_POST["cm"]; $num = (round($cmAsStr * 100.0)) / 100.0; $num *= 0.3937; $n = (round($num * 100.0)) / 100.0; echo $cmAsStr . " cm --> " . number_format((float)$n, 2, '.', '') . " in" . "
"; } else return ""; } } function convert_fttom() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["ft"]) > 0) { if (!is_numeric($_POST['ft'])) throw new Exception('Data entry is not numeric'); $ftAsStr = $_POST["ft"]; $num = (round($ftAsStr * 100.0)) / 100.0; $num *= 0.3048; $n = (round($num * 100.0)) / 100.0; echo $ftAsStr . " ft --> " . number_format((float)$n, 2, '.', '') . " m" . "
"; } else return ""; } } function convert_mtoft() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["m"]) > 0) { if (!is_numeric($_POST['m'])) throw new Exception('Data entry is not numeric'); $mAsStr = $_POST["m"]; $num = (round($mAsStr * 100.0)) / 100.0; $num /= 0.3048; $n = (round($num * 100.0)) / 100.0; echo $mAsStr . " m --> " . number_format((float)$n, 2, '.', '') . " ft" . "
"; } else return ""; } } function convert_mitokm() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["mi"]) > 0) { if (!is_numeric($_POST['mi'])) throw new Exception('Data entry is not numeric'); $miAsStr = $_POST["mi"]; $num = (round($miAsStr * 100.0)) / 100.0; $num *= 1.609; $n = (round($num * 100.0)) / 100.0; echo $miAsStr . " mi --> " . number_format((float)$n, 2, '.', '') . " km" . "
"; } else return ""; } } function convert_kmtomi() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["km"]) > 0) { if (!is_numeric($_POST['km'])) throw new Exception('Data entry is not numeric'); $kmAsStr = $_POST["km"]; $num = (round($kmAsStr * 100.0)) / 100.0; $num *= 0.6214; $n = (round($num * 100.0)) / 100.0; echo $kmAsStr . " km --> " . number_format((float)$n, 2, '.', '') . " mi" . "
"; } else return ""; } } function convert_galtoL() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["gal"]) > 0) { if (!is_numeric($_POST['gal'])) throw new Exception('Data entry is not numeric'); $galAsStr = $_POST["gal"]; $num = (round($galAsStr * 100.0)) / 100.0; $num *= 3.785; $n = (round($num * 100.0)) / 100.0; echo $galAsStr . " gal --> " . number_format((float)$n, 2, '.', '') . " L" . "
"; } else return ""; } } function convert_Ltogal() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["L"]) > 0) { if (!is_numeric($_POST['L'])) throw new Exception('Data entry is not numeric'); $LAsStr = $_POST["L"]; $num = (round($LAsStr * 100.0)) / 100.0; $num /= 3.785; $n = (round($num * 100.0)) / 100.0; echo $LAsStr . " L --> " . number_format((float)$n, 2, '.', '') . " gal" . "
"; } else return ""; } } function convert_oztog() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["oz"]) > 0) { if (!is_numeric($_POST['oz'])) throw new Exception('Data entry is not numeric'); $ozAsStr = $_POST["oz"]; $num = (round($ozAsStr * 100.0)) / 100.0; $num *= 28.35; $n = (round($num * 100.0)) / 100.0; echo $ozAsStr . " oz --> " . number_format((float)$n, 2, '.', '') . " g" . "
"; } else return ""; } } function convert_gtooz() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["g"]) > 0) { if (!is_numeric($_POST['g'])) throw new Exception('Data entry is not numeric'); $gAsStr = $_POST["g"]; $num = (round($gAsStr * 100.0)) / 100.0; $num /= 28.35; $n = (round($num * 100.0)) / 100.0; echo $gAsStr . " g --> " . number_format((float)$n, 2, '.', '') . " oz" . "
"; } else return ""; } } function convert_lbtokg() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["lb"]) > 0) { if (!is_numeric($_POST['lb'])) throw new Exception('Data entry is not numeric'); $lbAsStr = $_POST["lb"]; $num = (round($lbAsStr * 100.0)) / 100.0; $num *= 0.4536; $n = (round($num * 100.0)) / 100.0; echo $lbAsStr . " lb --> " . number_format((float)$n, 2, '.', '') . " kg" . "
"; } else return ""; } } function convert_kgtolb() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if (strlen($_POST["kg"]) > 0) { if (!is_numeric($_POST['kg'])) throw new Exception('Data entry is not numeric'); $kgAsStr = $_POST["kg"]; $num = (round($kgAsStr * 100.0)) / 100.0; $num *= 2.205; $n = (round($num * 100.0)) / 100.0; echo $kgAsStr . " kg --> " . number_format((float)$n, 2, '.', '') . " lb" . "
"; } else return ""; } } ?>