C'est la vie.
Loading search...

Temperature Converter

Temperature Converter Celsius $f2k=5/9*($_POST['degrees']-32)+273.15; //Fahrenheit -> Kelvin //From Celsius $c2f=$_POST['degrees']*9/5+32; //Celsius -> Fahrenheit $c2k=$_POST['degrees']+273.15; //Celsius -> Kelvin //From Kelvin $k2f=($_POST['degrees']-273.15)*1.8+32; //Kelvin -> Fahrenheit $k2c=$_POST['degrees']-273.15; //Kelvin -> Celsius if(isset($_POST['submit'])) { if($_POST['scalefrom'] == fahrenheit){ //If we're coming from Fahrenheit... if($_POST['scaleto'] == fahrenheit){ //...and going to Fahrenheit, it's the same. echo $_POST['degrees'] . 'ºF'; }elseif($_POST['scaleto'] == celsius){ //...and going to Celsius, do $f2c. echo $f2c . 'ºC'; }elseif($_POST['scaleto'] == kelvin){ //...and going to Kelvin, do $f2k. echo $f2k . 'K';} } if($_POST['scalefrom'] == celsius){ //If we're coming from Celsius... if($_POST['scaleto'] == celsius){ //...and going to Celsius, it's the same. echo $_POST['degrees'] . 'ºC'; }elseif($_POST['scaleto'] == fahrenheit){ //...and going to Fahrenheit, do $c2f. echo $c2f . 'ºF'; }elseif($_POST['scaleto'] == kelvin){ //...and going to Kelvin, do $c2k. echo $c2k . 'K';} } if($_POST['scalefrom'] == kelvin){ //If we're coming from Kelvin... if($_POST['scaleto'] == kelvin){ //...and going to Kelvin, it's the same. echo $_POST['degrees'] . 'K'; }elseif($_POST['scaleto'] == fahrenheit){ //...and going to Fahrenheit, do $k2f. echo $k2f . 'ºF'; }elseif($_POST['scaleto'] == celsius){ //...and going to Celsius, do $k2c. echo $k2c . 'ºC';} } }else{ echo 'N/A';} ?>