脚本宝典收集整理的这篇文章主要介绍了PHP输出日历表代码实例,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<div class="js-codecode">
<PRe class="brush:PHP;">
<!DOCTYPE htML PubLIC "-//W3C//DTD XHTML 1.0 TransITional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html XMlns="http://www.w3.org/1999/xhtml">
function PrintMon($year,$mon)
{
date_default_timezone_set("Asia/Shanghai");
global $MONTH;
global $enMONTH;
global $WEEK;
global $BACKCOLOR;
$startdate =strtotime("1 $enMONTH[$mon] $year"); //获取查询的年月
$enddate = strtotime("+1 month",$startdate); //获取下一个月的开始日期作为月历输出的截止时间
$theDate = getdate($startdate); //把日期转化为字符串格式
$color = $BACKCOLOR[$mon]; //设置月历的背景颜色
echo("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"$color\">");
$ym = $year . "年". $MONTH[$mon];
echo("
$theWeek = $theDate[wday];//判断当天是星期几
for ($i=0; $i<6; $i++)
{
echo("<tr>");
for ($j=0; $j<7; $j++)
{
echo("<td width=\"90\",height=\"40\" align=\"center\" >");
if ($startdate < $enddate && $theWeek == $j)//把日期输出到对应的星期几所在列,并注意不要超出本月日期
{
$theDay = $theDate[mday];
echo("
echo("</table");
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<?php
$year = $_POST['myyear'];
$month = $_POST['myMonth'];
if (is_numeric($year) && $year >= 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输出日历表代码实例全部内容,希望文章能够帮你解决PHP输出日历表代码实例所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。