Busca la funcion que necesitas!

viernes, 21 de enero de 2011

PHP - Convertir de Celsius a Farenheit, Kelvin & Rankine

Bueno este source es de cuando yo estudié el primer semestre del bachillerato, conveirte de grados celsius a farenheit, kelvin o rankine, así cuando hacía mi tarea no tenía que usar la calculadora solo abrir localhost y poner los datos ahí.

<?
/******************************
* By Linkgl                  *
* 12/02/10                   *
* Formula de wikipedia       *
* ***************************/   
if(!isset($_POST['num']))
{
?>
<form action="#" method="post">
<input type="text" name="num">
<input type="radio" name="r1" value="f">F
<input type="radio" name="r1" value="k">K
<input type="radio" name="r1" value="r">R

<input type="submit" value="enviar">
</form>
<?
}
else
{
  $num=$_POST['num'];
  switch($_POST['r1'])
  {
    case "f":
      echo $num*9/5+32;
      break;
    case "k":
      echo $num + 273.15;
      break;
    case "r":
      $op=$num + 273.15;
      echo $op*9/5;
      break;
  }
}
?>

No hay comentarios:

Publicar un comentario