php实现的日历程序

前端之家收集整理的这篇文章主要介绍了php实现的日历程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了PHP实现的日历程序。分享给大家供大家参考。具体如下:

PHP;"> PHP ////判断$Year和$Month是否为空,如果为空就获取系统当前日期,否则用$_GET获取 $Year = empty($_GET['Year']) ? date("Y"): $_GET["Year"]; $Month = empty($_GET['Month']) ? date("m"): $_GET["Month"]; ////获取当前日期//// $Today = date("Ymj"); ////初始化日期数组//// $Maxday = array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"); $Maxday_count = count($Maxday); ////初始化星期数组//// $Weekday = array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); $Weekday_count = count($Weekday); $daynum = 0; $space = "
PHP" method="post" name="linked"> >" onClick="javascript:document.linked.submit();" name="Month"><<" onClick="javascript:document.linked.submit();" name="Month">>>PHP ////打印星期列表//// while(list(,$Weekvalue) = each($Weekday)) echo "".$Weekvalue."删除一个值,也就是删除31这个值. if($Month == 4 or $Month == 6 or $Month == 9 or $Month == 11) { array_pop($Maxday); $Maxday_count--; } //先判断月份是否为2月,如果是的话再判断年份是否为闰年,如果是的话就从数组尾部移除2个值,否则就移除3个值. if($Month == 2) { if($Year % 4 == 0) { array_pop($Maxday); array_pop($Maxday); $Maxday_count-=2; } else { array_pop($Maxday); array_pop($Maxday); array_pop($Maxday); $Maxday_count-=3; } } ////打印日期//// while($daynum < $Maxday_count) { echo "退出此轮循环(换行打印) if(($DayWeek+1) % 7 == 0) { $col++; break; } } echo "

运行效果如下:

希望本文所述对大家的PHP程序设计有所帮助。

原文链接:https://www.f2er.com/php/21737.html

猜你在找的PHP相关文章