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 git.master, git.master_jit, rfc.property-hooks
int(31) int(28) int(31) int(30) int(29) int(29) int(29) int(28) int(31) int(31) int(31) int(30) int(31) int(31) int(31)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
50 ms | 401 KiB | 8 Q