Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //el año del cual se espera saber la edad
- $anyo_calculo = 2020;
- //edad
- $edad = 23;
- echo "La edad a calcular es: " . $edad . "<br>";
- //año
- $anyo = 2021;
- echo "El año a actual es: " . $anyo . "<br>";
- if((is_null($edad) || is_null($anyo)) || ($edad < 0 || $anyo < 0)){
- echo "edad o año incorrectos";
- } elseif ($anyo > $anyo_calculo) {
- echo "El año introducido es superior al $anyo_calculo";
- } else {
- $total = ($anyo_calculo - $anyo) + $edad;
- echo "En $anyo_calculo la persona tendrá una edad de: " . $total . " años<br>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement