3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getHolidays($year = null) { if ($year === null) { $year = intval(date('Y')); } $easterDate = easter_date($year); $easterDay = date('j', $easterDate); $easterMonth = date('n', $easterDate); $easterYear = date('Y', $easterDate); $holidays = array( // These days have a fixed date mktime(0, 0, 0, 1, 1, $year), // 1er janvier mktime(0, 0, 0, 5, 1, $year), // Fête du travail mktime(0, 0, 0, 5, 8, $year), // Victoire des alliés mktime(0, 0, 0, 7, 14, $year), // Fête nationale mktime(0, 0, 0, 8, 15, $year), // Assomption mktime(0, 0, 0, 11, 1, $year), // Toussaint mktime(0, 0, 0, 11, 11, $year), // Armistice mktime(0, 0, 0, 12, 25, $year), // Noel // These days have a date depending on easter mktime(0, 0, 0, $easterMonth, $easterDay + 2, $easterYear), mktime(0, 0, 0, $easterMonth, $easterDay + 40, $easterYear), mktime(0, 0, 0, $easterMonth, $easterDay + 50, $easterYear), ); sort($holidays); return $holidays; } var_dump(array_map(function ($item) { return date('Y-m-d H:i:s', $item); }, getHolidays(2014)));
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
array(11) { [0]=> string(19) "2014-01-01 00:00:00" [1]=> string(19) "2014-04-22 00:00:00" [2]=> string(19) "2014-05-01 00:00:00" [3]=> string(19) "2014-05-08 00:00:00" [4]=> string(19) "2014-05-30 00:00:00" [5]=> string(19) "2014-06-09 00:00:00" [6]=> string(19) "2014-07-14 00:00:00" [7]=> string(19) "2014-08-15 00:00:00" [8]=> string(19) "2014-11-01 00:00:00" [9]=> string(19) "2014-11-11 00:00:00" [10]=> string(19) "2014-12-25 00:00:00" }
Output for hhvm-3.10.0 - 3.12.0
Fatal error: Call to undefined function easter_date() in /in/nqAoQ on line 10
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/nqAoQ on line 37
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 T_FUNCTION, expecting ')' in /in/nqAoQ on line 37
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/nqAoQ on line 37
Process exited with code 255.