PHP输出日历表代码实例

这篇文章主要介绍了PHP输出日历表代码实例,本文直接给出代码实例,需要的朋友可以参考下

   月历表 "); $ym = $year . "年". $MONTH[$mon]; echo("

$ym

"); echo(""); for ($i=0; $i<7; $i++) //输出星期几 { echo(""); echo("

$WEEK[$i]

"); echo(""); } echo(""); $theWeek = $theDate[wday];//判断当天是星期几 for ($i=0; $i<6; $i++) { echo(""); for ($j=0; $j<7; $j++) { echo(""); if ($startdate < $enddate && $theWeek == $j)//把日期输出到对应的星期几所在列,并注意不要超出本月日期 { $theDay = $theDate[mday]; echo("

$theDay

"); $startdate = strtotime("+1 day", $startdate); //日期前移1天 $theDate = getdate($startdate);//更新日期 $theWeek = ($theWeek + 1) % 7;//更新星期 } echo(""); } echo(""); if ($startdate == $enddate) //如果已经输出全部日期,结束循环 { $i = 6; } } echo("

请输入要查看的年号和月份(查询范围为1970年1月1日至2038年)

= 1970 && $year <2038) { if (is_numeric($month) && $month >= 1 && $month <=12) { PrintMon($year, $month); } else if($month != NULL) { echo("月份不对" . "
"); } } else if($year != NULL) { echo("年份不对" . "
"); } ?>

以上就是PHP输出日历表代码实例的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » PHP编程