3v4l.org

run code in 300+ PHP versions simultaneously
<?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('');

preferences:
41.07 ms | 402 KiB | 5 Q