资源描述:
《PHP输出日历表代码实例_》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、PHP输出日历表代码实例_这篇文章主要介绍了PHP输出日历表代码实例,本文挺直给出代码实例,需要的伴侣可以参考下!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"""htmlxmlns=""headmetahttp-equiv="Content-Type"content="text/html;charset=utf-8"/title月历表/title?php$MONTH=array("元月","一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");$enMON
2、TH=array("元月","January","February","Marcy","April","May","June","July","August","September","October","November","December");$WEEK=array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");$BACKCOLOR=array("#FFC","#FFF","#9F6","#FFC","#6F0","#6F6","#F90","#F06","#F00","#FC3","#FF6","#F99");functionPrintMo
3、n($year,$mon){date_default_timezone_set("Asia/Shanghai");global$MONTH;global$enMONTH;global$WEEK;global$BACKCOLOR;$startdate=strtotime("1$enMONTH[$mon]$year");//猎取查询的年月$enddate=strtotime("+1month",$startdate);//猎取下一个月的开头日期作为月历输出的截止时间$theDate=getdate($startdate);//把日期转化为字符串格式$color=$BACKCOLOR[$mon
4、];//设置月历的背景颜色echo("tableborder="1"cellspacing="0"cellpadding="0"bgcolor="$color"");$ym=$year."年".$MONTH[$mon];echo("captionh1$ym/h1/caption");echo("tr");for($i=0;$i7;$i++)//输出星期几{echo("tdwidth="90",height="40"align="center"");echo("h2$WEEK[$i]/h2");echo("/td");}echo("/tr");$theWeek=
5、$theDate[wday];//推断当天是星期几for($i=0;$i6;$i++){echo("tr");for($j=0;$j7;$j++){echo("tdwidth="90",height="40"align="center"");if($startdate$enddate$theWeek==$j)//把日期输出到对应的星期几所在列,并留意不要超出本月日期{$theDay=$theDate[mday];echo("h2$theDay/h2");$startdate=strtotime("+1day",$startdate);//日期前移1天$theDate=getd
6、ate($startdate);//更新日期$theWeek=($theWeek+1)%7;//更新星期}echo("/td");}echo("/tr");if($startdate==$enddate)//假如已经输出全部日期,结束循环{$i=6;}}echo("/table");}?/headbodyformmethod="post"action="?phpecho$_SERVER['PHP_SELF'];?"h1请输入要查看的年号和月份(查询范围为1970年1月1日至2038年)/h1inputtype="text"name="myYear"年inputtype="text"nam
7、e="myMonth"月inputtype="submit"/form?php$year=$_POST['myYear'];$month=$_POST['myMonth'];if(is_numeric($year)$year=1970$year2038){if(is_numeric($month)$month=1$month=12){PrintMon($year,$month);}elseif($month!=NULL){echo(