3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function daysInMonth($month, $year) { $daysBetweenMonths = [0, 31, 59 + ($year%4 === 0), 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 + ($year%4 === 0)]; $prev = $daysBetweenMonths[$month - 1]; $current = $daysBetweenMonths[$month]; return $current - $prev; } for ($y = 2000; $y < 2004; $y++) { for ($m = 1; $m < 13; $m++) { echo 'days in '.$m.'/'.$y.' are :'. daysInMonth($m, $y)."\n"; } echo "\n\n"; }
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
days in 1/2000 are :31 days in 2/2000 are :29 days in 3/2000 are :30 days in 4/2000 are :30 days in 5/2000 are :31 days in 6/2000 are :30 days in 7/2000 are :31 days in 8/2000 are :31 days in 9/2000 are :30 days in 10/2000 are :31 days in 11/2000 are :30 days in 12/2000 are :32 days in 1/2001 are :31 days in 2/2001 are :28 days in 3/2001 are :31 days in 4/2001 are :30 days in 5/2001 are :31 days in 6/2001 are :30 days in 7/2001 are :31 days in 8/2001 are :31 days in 9/2001 are :30 days in 10/2001 are :31 days in 11/2001 are :30 days in 12/2001 are :31 days in 1/2002 are :31 days in 2/2002 are :28 days in 3/2002 are :31 days in 4/2002 are :30 days in 5/2002 are :31 days in 6/2002 are :30 days in 7/2002 are :31 days in 8/2002 are :31 days in 9/2002 are :30 days in 10/2002 are :31 days in 11/2002 are :30 days in 12/2002 are :31 days in 1/2003 are :31 days in 2/2003 are :28 days in 3/2003 are :31 days in 4/2003 are :30 days in 5/2003 are :31 days in 6/2003 are :30 days in 7/2003 are :31 days in 8/2003 are :31 days in 9/2003 are :30 days in 10/2003 are :31 days in 11/2003 are :30 days in 12/2003 are :31
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/jTNaX on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/jTNaX on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/jTNaX on line 4
Process exited with code 255.