Temperature Converter - Pixeleco.com"; echo "

Temperature Converter

Convert

       Back to main page

 

"; if($from==''||$to=='') { echo "Please select both From and To"; exit; } if($from==$to) $tovalue=$fromvalue; else if($from=='C'&&$to=='F') { if($fromvalue<-273) die("From value is below absolute zero !"); $tovalue=($fromvalue*100)/180+32; } else if($from=='F'&&$to=='C') { $tovalue=((10*$fromvalue)-32)/18; if($tovalue<-273) die("Result is below absolute zero !"); } else if($from=='C'&&$to=='Kelvin') { if($fromvalue<-273) die("From value is below absolute zero !"); $tovalue=$fromvalue+273; } else if($from=='Kelvin'&&$to=='C') { $tovalue=$fromvalue-273; if($tovalue<-273) die("Result is below absolute zero !"); } else if($from=='Kelvin'&&$to=='F') { $tovalue=$fromvalue-273; if($tovalue<-273) die("Result is below absolute zero !"); $tovalue=($tovalue*100)/180+32; } else if($from=='F'&&$to=='Kelvin') { $tovalue=((10*$fromvalue)-32)/18; if($tovalue<-273) die("Result is below absolute zero !"); $tovalue=$tovalue+273; } if($fromvalue>1) $fromadd='s'; if($tovalue>1) $toadd='s'; $fromvalue=number_format($fromvalue); $tovalue=number_format($tovalue,3); echo "

Result

"; echo "

"; echo $fromvalue; echo ""." $from".$fromadd." = ".""; echo $tovalue; echo ""." $to

".$toadd; ?>