3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $today_y = date("Y"); $today_m = date("m"); $today_d = date("d"); list($birthday_y, $birthday_m, $birthday_d) = explode('/', str_replace('-','/',$birthday)); $age = $today_y - $birthday_y; //誕生日前なら1才引く if( $today_m*100 + $today_d < $birthday_m*100 + $birthday_d ){ $age--; } echo $age;
based on OK4Re
Output for 7.1.0 - 7.2.0
Notice: Undefined variable: birthday in /in/6qBko on line 6 Notice: Undefined offset: 1 in /in/6qBko on line 6 Notice: Undefined offset: 2 in /in/6qBko on line 6 Warning: A non-numeric value encountered in /in/6qBko on line 8 2015
Output for 7.0.0 - 7.0.20
Notice: Undefined variable: birthday in /in/6qBko on line 6 Notice: Undefined offset: 1 in /in/6qBko on line 6 Notice: Undefined offset: 2 in /in/6qBko on line 6 2015
Output for 5.5.0 - 5.6.28
Notice: Undefined variable: birthday in /in/6qBko on line 6 Notice: Undefined offset: 2 in /in/6qBko on line 6 Notice: Undefined offset: 1 in /in/6qBko on line 6 2015