3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // todays date $today = date("Ymd"); function age($birth_date){ list($birth_day,$birth_month,$birth_year) = explode("-",$birth_date); $year_diff = date("Y") - $birth_year; $month_diff = date("m") - $birth_month; $day_diff = date("d") - $birth_day; if ($day_diff < 0 && $month_diff==0){$year_diff--;} if ($day_diff < 0 && $month_diff < 0){$year_diff--;} return $year_diff; } //Call the age function age();
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function age(), 0 passed in /in/oqm7T on line 15 and exactly 1 expected in /in/oqm7T:5 Stack trace: #0 /in/oqm7T(15): age() #1 {main} thrown in /in/oqm7T on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.14
Warning: Missing argument 1 for age(), called in /in/oqm7T on line 15 and defined in /in/oqm7T on line 5 Notice: Undefined variable: birth_date in /in/oqm7T on line 6 Notice: Undefined offset: 1 in /in/oqm7T on line 6 Notice: Undefined offset: 2 in /in/oqm7T on line 6
Output for hhvm-3.12.0
Warning: age() expects exactly 1 parameter, 0 given in /in/oqm7T on line 6 Notice: Undefined variable: birth_date in /in/oqm7T on line 6 Warning: explode() expects parameter 2 to be string, null given in /in/oqm7T on line 6
Output for hhvm-3.10.0
Warning: age() expects exactly 1 parameter, 0 given in /in/oqm7T on line 6 Notice: Undefined variable: birth_date in /in/oqm7T on line 6 Notice: Undefined index: 1 in /in/oqm7T on line 6 Notice: Undefined index: 2 in /in/oqm7T on line 6
Output for 5.3.0 - 5.6.28
Warning: Missing argument 1 for age(), called in /in/oqm7T on line 15 and defined in /in/oqm7T on line 5 Notice: Undefined variable: birth_date in /in/oqm7T on line 6 Notice: Undefined offset: 2 in /in/oqm7T on line 6 Notice: Undefined offset: 1 in /in/oqm7T on line 6
Output for 5.1.0 - 5.2.17
Warning: Missing argument 1 for age(), called in /in/oqm7T on line 15 and defined in /in/oqm7T on line 5 Notice: Undefined variable: birth_date in /in/oqm7T on line 6 Notice: Undefined offset: 2 in /in/oqm7T on line 6 Notice: Undefined offset: 1 in /in/oqm7T on line 6
Output for 4.3.0 - 5.0.5
Warning: Missing argument 1 for age() in /in/oqm7T on line 5 Notice: Undefined offset: 2 in /in/oqm7T on line 6 Notice: Undefined offset: 1 in /in/oqm7T on line 6