新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章主要为大家展示了“PHP如何创建日历”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“PHP如何创建日历”这篇文章吧。
创新互联公司从2013年创立,是专业互联网技术服务公司,拥有项目网站设计制作、做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元宜川做网站,已为上家服务,为宜川各地企业和个人服务,联系电话:18982081108具体如下:
"; $calendar .= "$monthName $year "; $calendar .= ""; // Create the calendar headers foreach($daysOfWeek as $day) { $calendar .= " $day "; } // Create the rest of the calendar // Initiate the day counter, starting with the 1st. $currentDay = 1; $calendar .= ""; // The variable $dayOfWeek is used to // ensure that the calendar // display consists of exactly 7 columns. if ($dayOfWeek > 0) { $calendar .= " "; } $month = str_pad($month, 2, "0", STR_PAD_LEFT); while ($currentDay <= $numberDays) { // Seventh column (Saturday) reached. Start a new row. if ($dayOfWeek == 7) { $dayOfWeek = 0; $calendar .= " "; } $currentDayRel = str_pad($currentDay, 2, "0", STR_PAD_LEFT); $date = "$year-$month-$currentDayRel"; $calendar .= " "; $calendar .= ""; return $calendar; } //调用方法 echo build_calendar(05,2016); ?>$currentDay "; // Increment counters $currentDay++; $dayOfWeek++; } // Complete the row of the last week in month, if necessary if ($dayOfWeek != 7) { $remainingDays = 7 - $dayOfWeek; $calendar .= ""; } $calendar .= "
运行结果如下图所示:
以上是“PHP如何创建日历”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!