欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php如何實現(xiàn)日歷

這篇文章主要介紹“php如何實現(xiàn)日歷”,在日常操作中,相信很多人在php如何實現(xiàn)日歷問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”php如何實現(xiàn)日歷”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

創(chuàng)新互聯(lián)是一家專注于做網(wǎng)站、成都網(wǎng)站制作與策劃設(shè)計,淮安網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:淮安等地區(qū)?;窗沧鼍W(wǎng)站價格咨詢:18980820575

php實現(xiàn)日歷的方法:1、創(chuàng)建一個PHP示例文件并設(shè)置編碼為utf-8;2、創(chuàng)建table表格;3、通過mktime等函數(shù)獲取時間日期;4、通過for循環(huán)實現(xiàn)日歷功能即可。

php如何實現(xiàn)日歷

本文操作環(huán)境:Windows7系統(tǒng)、PHP7.1版、DELL G3電腦

php怎么實現(xiàn)日歷?

PHP實現(xiàn)的日歷功能示例

具體如下:

<?php
/*
 * Created by PhpStorm.
 * User: admin
 */
header("Content-Type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
$a=@$_GET["a"];
$b=@$_GET["b"];
if($a){
  $a=$a;
}else{
  $a=date('y');
}
if($b){
  $b=$b;
}else{
  $b=date('m');
}
$noe=mktime(0,0,0,$b,1,$a); //獲取當(dāng)前的月的一號
$year=date("Y",$noe); //當(dāng)前的年
$month=date("m",$noe); //當(dāng)前的月
$week=date("w",$noe); // 每個月的一號是星期幾
$days=date("t",$noe); //每個月的總天數(shù)
$day=date("d"); //獲取今天是幾號
$as=$year-1; //獲取上一年的年
$bs=$month-1; //獲取上個月
$bs=$month+1; // 獲取下個月
$as=$year+1; //獲取下一年
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>日歷</title>
  <style>
    table{
      border: 1px solid #050;
    }
    table th{
      background:#000;
      color:#fff;
      border: 2px solid #050;
    }
  </style>
</head>
<body>
 <table cellpadding="0" cellspacing="0">
   <tr>
     <th><a href="?a=<?php echo $as; ?>" rel="external nofollow" rel="external nofollow" ><<上一年</a></th>
     <th><a href="?b=<?php echo $bs; ?>" rel="external nofollow" rel="external nofollow" ><<上個月</a></th>
     <th><?php echo $year."-".$month."-".$day ?></th>
     <th><a href="?b=<?php echo $bs; ?>" rel="external nofollow" rel="external nofollow" >下個月>></a></th>
     <th><a href="?a=<?php echo $as; ?>" rel="external nofollow" rel="external nofollow" >下一年>></a></th>
   </tr>
   <tr>
     <th>星期日</th>
     <th>星期一</th>
     <th>星期二</th>
     <th>星期三</th>
     <th>星期四</th>
     <th>星期五</th>
     <th>星期六</th>
   </tr>
  <tr>
    <?php
    for($i=0;$i<$week;$i++){
      echo "<td>&nbsp;</td>"; //獲取當(dāng)月一號前面的空格
    }
    for($k=1;$k<=$days;$k++){
      if($k==$day){
        echo "<th>".$k."</th>"; //輸出今天是幾號
      }else{
        echo "<td>".$k."</td>"; //輸出當(dāng)月天數(shù)
      }
      if(($k+$week)%7==0){
        echo "<tr></tr>"; // 一周七天換行
      }
    }
    ?>
  </tr>
 </table>
</body>
</html>

運行結(jié)果:

php如何實現(xiàn)日歷

到此,關(guān)于“php如何實現(xiàn)日歷”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

新聞名稱:php如何實現(xiàn)日歷
分享網(wǎng)址:http://chinadenli.net/article36/gpdjsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化小程序開發(fā)、微信小程序、企業(yè)建站、網(wǎng)站制作、域名注冊

廣告

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

成都定制網(wǎng)站建設(shè)