好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > PHP實現(xiàn)簡單日歷類編寫

PHP實現(xiàn)簡單日歷類編寫

熱門標簽:電子地圖標注怎么修改 梧州市機器人外呼系統(tǒng)怎么樣 臨沂crm外呼系統(tǒng)平臺 地圖標注符號樣式有 如何在世界地圖標注 菏澤語音外呼系統(tǒng)運營商 廈門400電話辦理選易號網 公司外呼系統(tǒng)中心 天客通地圖標注

用PHP實現(xiàn)日歷類的編寫,供大家參考,具體內容如下

calendar.class.php

?php
/*
* 創(chuàng)建一個日歷類
*
*
*/
 //修改默認時區(qū)
 date_default_timezone_set("PRC");
 
 class Calendar {
  private $year;
 private $month;
 private $day; //當月總天數
 private $first_week; //每月的第一天是星期幾
 
 //構造函數
 function __construct() {
  $this->year = isset($_GET['year'])?$_GET['year']:date("Y");
  $this->month = isset($_GET["month"])?$_GET["month"]:date("m");
  $this->first_week = date("w", mktime(0, 0 ,0, $this->month, 1, $this->year));
  $this->day = date("t", mktime(0, 0 ,0, $this->month, 1, $this->year));
 }
 function showCalendar() {
 //  echo $this->year."年".$this->month."月".$this->first_week."天".$this->day;
   echo "table align='center'>"; //用表格輸出
   $this->chageDate("index.php"); //用于用戶調整年月份
  $this->weekList();//顯示星期
  $this->dayList(); //顯示天數
  
  echo "/table>";
 }
 //1、顯示星期
 private function weekList() {
  $week = array("日","一","二","三","四","五","六");
  echo "tr>";
   for ($i = 0; $i  count($week); $i++) {
   echo "th>".$week[$i]."/th>";
  }
  echo "/tr>";
 }
 //2.顯示天數
 private function dayList() {
  $color = "#2ca50c";
  echo "tr>";
  for ($i = 0; $i  $this->first_week; $i++) { //輸出空格,彌補當前月空缺部分
   echo "td bgcolor='#2ca50c'> /td>";
  }
  for ($k = 1; $i = $this->day; $k++) {
   $i++;
   if ($k == date("d")) echo "td id='nowd'>".$k."/td>"; //是今天,加效果
   else echo "td bgcolor=$color>".$k."/td>";
   if ($i % 7 == 0) {
   echo "/tr>tr>"; //每7天一次換行
   if ($i % 2 == 0) $color = "#2ca50c";
   else $color = "#9ddb27"; //實現(xiàn)各行換色的效果
   }
  }
  while ($i % 7 != 0) { //將剩余的空格補完
   echo "td bgcolor='#2ca50c'> /td>";
  $i++; 
  }
  echo "/tr>";
 }
  
 //3、用于用戶調整天數
 private function chageDate($url="index.php") {
  echo "tr>";
   echo "caption>h1>".$this->year."年".$this->month."月/h1>/caption>"; 
  echo "/tr>";
  echo "tr>";
  echo "td>"."a href='?".$this->prevYear($this->year,$this->month)."'>".""."/a>";
  echo "td>"."a href='?".$this->prevMonth($this->year,$this->month)."'>".""."/a>";
  
  echo "td colspan='3'>";
   echo 'select οnchange="window.location=\''.$url.'?year='+this.options[selectedIndex].value+\'month='.$this->month.''">';
    for ($year = 2038; $year >= 1970; $year--) {
    $selected = ($year == $this->year)?"selected":"";
    echo 'option '.$selected. ' value="'.$year.'">'.$year.'/option>';
    //echo 'option '.$selected.' value="'.$year.'">'.$year.'/option>';
   }
   echo "/select>";
   
  echo 'select name="month" οnchange="window.location=\''.$url.'?year='.$this->year.'month='+this.options[selectedIndex].value">';
  for($month=1;$month = 12;$month++){
   $selected1 = ($month == $this->month) ? "selected" : "";
   echo 'option '.$selected1.' value="'.$month.'">'.$month.'/option>';
  }
  echo '/select>';
  echo "/td>";
  
  
  echo "td>"."a href='?".$this->nextMonth($this->year,$this->month)."'>".">>"."/a>";
  echo "td>"."a href='?".$this->nextYear($this->year,$this->month)."'>".">"."/a>";
  echo "/tr>";
 }
 
 private function prevYear($year, $month) { //獲取上一年的數據
  $year--;
  if ($year  1970) $year = 1970;
  return "year={$year}month={$month}";
 }
 private function prevMonth($year, $month) {
  if ($month == 1) {
   $year--;
  if ($year  1970) $year = 1970;
  $month = 12;
  }else $month--; 
  return "year={$year}month={$month}";
 }
 private function nextYear($year, $month) { //獲取上一年的數據
  $year++;
  if ($year > 2038) $year = 2038;
  return "year={$year}month={$month}";
 }
 private function nextMonth($year, $month) {
  if ($month == 12) {
   $year++;
  if ($year > 2038) $year = 2038;
  $month = 1;
  }else $month++; 
  return "year={$year}month={$month}";
 }
 }

主頁 index.php

!doctype html>
html>
head>
meta charset="utf-8">
title>日歷顯示/title>
style>
 table {
 border:1px solid #050;
 margin: 100px auto;
 }
 th {
  width: 30px;
 background-color: #0CC;
 color: #fff;
 height: 30px;
 font-size: 20px;
 }
 #nowd {
  color: yellow;
 background: #F00;
 }
 td {
  width: 30px;
 text-align: center;
 
 height: 25px;
 color: #fff;
 }
 a {
 display: block;
 width: 35px;
 height: 35px;
 background: #0F9;
  text-decoration: none;
 text-align: center;
 line-height: 35px;
 }
 a:hover {
  background: #CF0;
 color: #fff;
 font-size: 20px;
 }
/style>
/head>
 
body>
 ?php
 include "calendar.class.php";
 $ca = new Calendar();
 $ca->showCalendar();
 ?>
/body>
/html>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • PHP實現(xiàn)的簡單日歷類
  • 一個比較不錯的PHP日歷類分享
  • PHP完整的日歷類(CLASS)

標簽:雞西 貴陽 瀘州 白城 綿陽 郴州 黃石 迪慶

巨人網絡通訊聲明:本文標題《PHP實現(xiàn)簡單日歷類編寫》,本文關鍵詞  PHP,實現(xiàn),簡單,日歷,類,編寫,;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《PHP實現(xiàn)簡單日歷類編寫》相關的同類信息!
  • 本頁收集關于PHP實現(xiàn)簡單日歷類編寫的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 疾速追杀4在线| 轻点,好涨,太粗,大硬| 博人传博人鸣人×黑土视频| 韩国三力电影大合集视频在线观看| 国产69久久久欧美黑人A片| 国产欧美日韩网站| 特级特黄A片免费播放| 爽?好大?快?深点日本网站小说 | 日韩一页| 久久久久久精品免费啪啪国卢浮宫| 美女视频黄频a美女大全漫画| 黄色片子免费| 安国市| 国产美女裸体无遮挡免费视频| 国产欧美亚洲另类第一页| 2020韩国r级理论片在线观看 | 91天堂素人约啪| 禁忌亲生h肉男同| 688欧美人禽杂交狂配| 国产精品免费视频观看露| 国产一级婬片A片灌| 中文字幕制服诱惑| 男男高h情趣用品play小说| 嫩草影院黄| 国产在线观看| 台湾踩踏俱乐部| www.色.con| 少妇体内she精未汇编才| 国产真人91一级毛片做| 英语老师c了语文老师一节课| 杨幂一区二区三区免费看视频| 精品久久中文久久久| 久久久久亚洲AV色欲av| bdsmtube亚洲捆绑绳艺| 经典欧美gifxxoo动态图暗图| 大胸妹子被捏胸动态| 蜜桃影像传媒文化公司| 无码人妻精品一区二区三区网站| 东北大坑婬乱生活| 美女下面被揉出白浆视频| 性欧美xx|