PHP如何創建日歷-創新互聯

這篇文章主要為大家展示了“PHP如何創建日歷”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“PHP如何創建日歷”這篇文章吧。

創新互聯公司從2013年創立,是專業互聯網技術服務公司,擁有項目網站設計制作、做網站網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元宜川做網站,已為上家服務,為宜川各地企業和個人服務,聯系電話:18982081108

具體如下:

<?php
function build_calendar($month,$year) {
  // Create array containing abbreviations of days of week.
  $daysOfWeek = array('S','M','T','W','T','F','S');
  // What is the first day of the month in question?
  $firstDayOfMonth = mktime(0,0,0,$month,1,$year);
  // How many days does this month contain?
  $numberDays = date('t',$firstDayOfMonth);
  // Retrieve some information about the first day of the
  // month in question.
  $dateComponents = getdate($firstDayOfMonth);
  // What is the name of the month in question?
  $monthName = $dateComponents['month'];
  // What is the index value (0-6) of the first day of the
  // month in question.
  $dayOfWeek = $dateComponents['wday'];
  // Create the table tag opener and day headers
  $calendar = "<table class='calendar'>";
  $calendar .= "<caption>$monthName $year</caption>";
  $calendar .= "<tr>";
  // Create the calendar headers
  foreach($daysOfWeek as $day) {
     $calendar .= "<th class='header'>$day</th>";
  }
  // Create the rest of the calendar
  // Initiate the day counter, starting with the 1st.
  $currentDay = 1;
  $calendar .= "</tr><tr>";
  // The variable $dayOfWeek is used to
  // ensure that the calendar
  // display consists of exactly 7 columns.
  if ($dayOfWeek > 0) {
     $calendar .= "<td colspan='$dayOfWeek'>&nbsp;</td>";
  }
  $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 .= "</tr><tr>";
     }
     $currentDayRel = str_pad($currentDay, 2, "0", STR_PAD_LEFT);
     $date = "$year-$month-$currentDayRel";
     $calendar .= "<td class='day' rel='$date'>$currentDay</td>";
     // Increment counters
     $currentDay++;
     $dayOfWeek++;
  }
  // Complete the row of the last week in month, if necessary
  if ($dayOfWeek != 7) {
     $remainingDays = 7 - $dayOfWeek;
     $calendar .= "<td colspan='$remainingDays'>&nbsp;</td>";
  }
  $calendar .= "</tr>";
  $calendar .= "</table>";
  return $calendar;
}
//調用方法
echo build_calendar(05,2016);
?>

運行結果如下圖所示:

PHP如何創建日歷

以上是“PHP如何創建日歷”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注創新互聯行業資訊頻道!

網站名稱:PHP如何創建日歷-創新互聯
地址分享:http://m.kartarina.com/article4/cdcoie.html

成都網站建設公司_創新互聯,為您提供營銷型網站建設網站設計公司自適應網站網站內鏈App設計品牌網站設計

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都seo排名網站優化
主站蜘蛛池模板: 中文无码vs无码人妻| 精品无码久久久久久久久久| 亚洲AV无码之国产精品| 黑人巨大无码中文字幕无码| 夜夜添无码试看一区二区三区 | 免费无码又爽又刺激网站直播 | 亚洲av日韩aⅴ无码色老头| 精品无码一级毛片免费视频观看 | 精品无码久久久久久尤物| 在线精品免费视频无码的| 熟妇人妻AV无码一区二区三区| 毛片亚洲AV无码精品国产午夜 | 日韩亚洲AV无码一区二区不卡| 无码人妻精品一区二区蜜桃 | 亚洲av无码天堂一区二区三区 | 亚洲国产精品无码久久青草| 精品久久久久久无码专区不卡| 粉嫩高中生无码视频在线观看| 色国产色无码色欧美色在线| 久久亚洲精品无码AV红樱桃| 人妻无码一区二区三区| 亚洲精品~无码抽插| 无码人妻一区二区三区精品视频| 精品亚洲A∨无码一区二区三区| 中文字幕乱码无码人妻系列蜜桃| 无码专区HEYZO色欲AV| 亚洲av中文无码字幕色不卡| 久久久无码精品亚洲日韩蜜臀浪潮| 中文字字幕在线中文无码| 九九久久精品无码专区| 国产精品第一区揄拍无码| 东京热一精品无码AV| 亚洲a∨无码精品色午夜| 亚洲日韩国产二区无码| 亚洲youwu永久无码精品| 亚洲精品无码国产片| 国产成人无码AV在线播放无广告| 色综合99久久久无码国产精品| 黑人巨大无码中文字幕无码| 国产成年无码久久久久下载| 色欲AV无码一区二区三区|