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
Notice: Undefined offset: 1 in /in/vnSfP on line 6 Notice: Undefined offset: 2 in /in/vnSfP on line 6 Warning: A non-numeric value encountered in /in/vnSfP on line 9
Output for 7.0.0 - 7.0.14
Notice: Undefined offset: 1 in /in/vnSfP on line 6 Notice: Undefined offset: 2 in /in/vnSfP on line 6
Output for 5.3.0 - 5.6.28
Notice: Undefined offset: 2 in /in/vnSfP on line 6 Notice: Undefined offset: 1 in /in/vnSfP on line 6
Output for 4.3.0 - 5.2.17
Notice: Undefined offset: 2 in /in/vnSfP on line 6 Notice: Undefined offset: 1 in /in/vnSfP on line 6