3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(!function_exists('cal_days_in_month')) { function cal_days_in_month($calendar, $month, $year) { return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31); } if (!defined('CAL_GREGORIAN')) { define('CAL_GREGORIAN', 1); } //tests var_dump(cal_days_in_month(CAL_GREGORIAN, 1, 2014)); //31 var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 2014)); //28 var_dump(cal_days_in_month(CAL_GREGORIAN, 10, 2014)); //31 var_dump(cal_days_in_month(CAL_GREGORIAN, 11, 2014)); //30 //some leap years - expect 29 for all var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 1804)); var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 2000)); var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 2056)); var_dump(cal_days_in_month(CAL_GREGORIAN, 2, 1994)); //some invalid ones: var_dump(cal_days_in_month(CAL_GREGORIAN, 1, 1)); var_dump(cal_days_in_month(CAL_GREGORIAN, 14, 2014)); //might be feb 2015? var_dump(cal_days_in_month(CAL_GREGORIAN, 1, 2014000)); //the far far future? var_dump(cal_days_in_month(CAL_GREGORIAN, 0, 2014)); //do we handle zero? var_dump(cal_days_in_month(CAL_GREGORIAN, -1, 2014)); //how about negative? var_dump(cal_days_in_month(CAL_GREGORIAN, 1, 0)); //and years? var_dump(cal_days_in_month(CAL_GREGORIAN, 1, -1)); //negative years?
Output for 5.4.0 - 5.4.32
Parse error: syntax error, unexpected end of file in /in/vTbfW on line 34
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.1 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected $end in /in/vTbfW on line 34
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/vTbfW on line 34
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected $ in /in/vTbfW on line 34
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/vTbfW on line 34
Process exited with code 255.

preferences:
232.94 ms | 1399 KiB | 123 Q