最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP簡(jiǎn)單創(chuàng)建日歷的方法

 更新時(shí)間:2016年05月03日 10:31:18   作者:懶人  
這篇文章主要介紹了PHP簡(jiǎn)單創(chuàng)建日歷的方法,

本文實(shí)例講述了PHP簡(jiǎn)單創(chuàng)建日歷的方法。分享給大家供大家參考,具體如下:

<?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;
}
//調(diào)用方法
echo build_calendar(05,2016);
?>

運(yùn)行結(jié)果如下圖所示:

關(guān)于在線顯示日期還可參考本站在線工具:

在線萬(wàn)年歷日歷

網(wǎng)頁(yè)萬(wàn)年歷日歷

在線萬(wàn)年歷黃歷flash版

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《php日期與時(shí)間用法總結(jié)》、《PHP數(shù)學(xué)運(yùn)算技巧總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫(kù)操作入門(mén)教程》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 解決Laravel5.x的php artisan migrate數(shù)據(jù)庫(kù)遷移創(chuàng)建操作報(bào)錯(cuò)SQLSTATE[42000]

    解決Laravel5.x的php artisan migrate數(shù)據(jù)庫(kù)遷移創(chuàng)建操作報(bào)錯(cuò)SQLSTATE[42000]

    這篇文章主要介紹了解決Laravel5.x的php artisan migrate數(shù)據(jù)庫(kù)遷移創(chuàng)建操作報(bào)錯(cuò)SQLSTATE[42000],需要的朋友可以參考下
    2020-04-04
  • ThinkPHP路由詳解

    ThinkPHP路由詳解

    ThinkPHP路由通俗的說(shuō),他是一個(gè)url的傳輸規(guī)則,例如:index.php?g=Home&m=Index&a=price 這個(gè)規(guī)則也是可以變化的,& 可以設(shè)置為@或者其他,規(guī)則主要有pathinfo等,在設(shè)置偽靜態(tài)的時(shí)候也用的著他
    2015-07-07
  • php實(shí)現(xiàn)SAE上使用storage上傳與下載文件的方法

    php實(shí)現(xiàn)SAE上使用storage上傳與下載文件的方法

    這篇文章主要介紹了php實(shí)現(xiàn)SAE上使用storage上傳與下載文件的方法,實(shí)例分析了基于SaeStorage類(lèi)實(shí)現(xiàn)文件傳輸?shù)募记?需要的朋友可以參考下
    2015-06-06
  • WIN8.1下搭建PHP5.6環(huán)境

    WIN8.1下搭建PHP5.6環(huán)境

    很多人喜歡用linux搭建php網(wǎng)頁(yè)語(yǔ)言運(yùn)行環(huán)境,但由于linux高度自定義化,經(jīng)常需要root運(yùn)行命令,略顯高端,相對(duì)應(yīng)的微軟的windows操作系統(tǒng),用戶(hù)體驗(yàn)不錯(cuò),可以借助windows自帶的IIS組件+PHP程序包,搭建一個(gè)合適的運(yùn)行環(huán)境。
    2015-04-04
  • PHP實(shí)現(xiàn)文件上傳與下載的示例代碼

    PHP實(shí)現(xiàn)文件上傳與下載的示例代碼

    這篇文章主要為大家詳細(xì)介紹了PHP實(shí)現(xiàn)文件上傳與下載功能的相關(guān)知識(shí),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2023-12-12
  • 詳細(xì)分析PHP 命名空間(namespace)

    詳細(xì)分析PHP 命名空間(namespace)

    這篇文章主要介紹了PHP 命名空間(namespace)的的相關(guān)資料,文中講解非常詳細(xì),實(shí)例代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-06-06
  • PHP面向接口編程 耦合設(shè)計(jì)模式 簡(jiǎn)單范例

    PHP面向接口編程 耦合設(shè)計(jì)模式 簡(jiǎn)單范例

    了解些面向?qū)ο蟮闹R(shí),自己寫(xiě)了段代碼測(cè)試一下,歡迎高手指點(diǎn)
    2011-03-03
  • PHP CURL實(shí)現(xiàn)模擬登陸并上傳文件操作示例

    PHP CURL實(shí)現(xiàn)模擬登陸并上傳文件操作示例

    這篇文章主要介紹了PHP CURL實(shí)現(xiàn)模擬登陸并上傳文件操作,結(jié)合實(shí)例形式分析了PHP使用curl進(jìn)行模擬登陸與文件傳輸操作具體實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2020-01-01
  • 使用PHP的日期與時(shí)間函數(shù)技巧

    使用PHP的日期與時(shí)間函數(shù)技巧

    任何一種語(yǔ)言,日期和時(shí)間函數(shù)都是我們常使用的,下面就教你PHP下的日期和時(shí)間的技巧
    2008-04-04
  • PHP 設(shè)計(jì)模式之觀察者模式介紹

    PHP 設(shè)計(jì)模式之觀察者模式介紹

    觀察者模式定義對(duì)象的一對(duì)多依賴(lài),這樣一來(lái),當(dāng)一個(gè)對(duì)象改變狀態(tài)時(shí),它的所有依賴(lài)者都會(huì)收到通知并自動(dòng)更新!
    2012-02-02

最新評(píng)論

崇文区| 淅川县| 丰原市| 济宁市| 睢宁县| 平和县| 马鞍山市| 库尔勒市| 景泰县| 平陆县| 山东| 荣昌县| 灵宝市| 阿城市| 三都| 康平县| 嘉峪关市| 五台县| 布拖县| 茶陵县| 榆社县| 普洱| 苍山县| 大田县| 陈巴尔虎旗| 彭水| 迭部县| 蒙城县| 开鲁县| 郴州市| 云和县| 马边| 于都县| 岳普湖县| 奉贤区| 华阴市| 海南省| 五家渠市| 颍上县| 潞西市| 竹山县|