3v4l.org

run code in 300+ PHP versions simultaneously
<?php //fecha actual $dia=date(j); $mes=date(n); $ano=date(Y); //fecha de nacimiento $dianaz=2; $mesnaz=6; $anonaz=1983; //si el mes es el mismo pero el día inferior aun no ha cumplido años, le quitaremos un año al actual if (($mesnaz == $mes) && ($dianaz > $dia)) { $ano=($ano-1); } //si el mes es superior al actual tampoco habrá cumplido años, por eso le quitamos un año al actual if ($mesnaz > $mes) { $ano=($ano-1);} //ya no habría mas condiciones, ahora simplemente restamos los años y mostramos el resultado como su edad $edad=($ano-$anonaz); print $edad; ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Undefined constant "j" in /in/PRVeu:4 Stack trace: #0 {main} thrown in /in/PRVeu on line 4
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant j - assumed 'j' (this will throw an Error in a future version of PHP) in /in/PRVeu on line 4 Warning: Use of undefined constant n - assumed 'n' (this will throw an Error in a future version of PHP) in /in/PRVeu on line 5 Warning: Use of undefined constant Y - assumed 'Y' (this will throw an Error in a future version of PHP) in /in/PRVeu on line 6 32
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
Notice: Use of undefined constant j - assumed 'j' in /in/PRVeu on line 4 Notice: Use of undefined constant n - assumed 'n' in /in/PRVeu on line 5 Notice: Use of undefined constant Y - assumed 'Y' in /in/PRVeu on line 6 32

preferences:
164.58 ms | 403 KiB | 226 Q