Advertisement
Guest User

Ejercicio5-1.php

a guest
Oct 4th, 2015
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2.     //el año del cual se espera saber la edad
  3.     $anyo_calculo = 2020;
  4.     //edad
  5.     $edad = 23;
  6.     echo "La edad a calcular es: " . $edad . "<br>";
  7.     //año
  8.     $anyo = 2021;
  9.     echo "El año a actual es: " . $anyo . "<br>";
  10.  
  11.     if((is_null($edad) || is_null($anyo)) || ($edad < 0 || $anyo < 0)){
  12.         echo "edad o año incorrectos";
  13.     } elseif ($anyo > $anyo_calculo) {
  14.         echo "El año introducido es superior al $anyo_calculo";
  15.     } else {
  16.         $total = ($anyo_calculo - $anyo) + $edad;
  17.         echo "En $anyo_calculo la persona tendrá una edad de: " . $total . " años<br>";
  18.     }
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement