// $year传进去的年
// $month 传进去的月份
function day_num($year,$month)
{
$big_month=array(1,3,5,7,8,10,12);
$sm_month=array(4,6,9,11);
if(in_array($month,$big_month))
{
$day_num=31;
}
else if(in_array($month,$sm_month))
{
$day_num=30;
}
else
{
if($year%4==0 && ($year%100!=0 || $year%400==0))//闰年
{
$day_num=29;
}
else
{
$day_num=28;
}
}
return $day_num;
}
$year = ‘2015‘;
$month = ‘6‘;
echo day_num($year,$month);
时间: 2024-10-11 18:05:00