首頁 >後端開發 >php教程 >日曆表格

日曆表格

WBOY
WBOY原創
2016-07-25 08:50:37993瀏覽
";
  • }
  • public function getEndTR( ) {
  • $this->retunrhtml .= "
  • ";
  • } protected function getDay() { return $this->day; } protected function getMonth() { return $this->month; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } }} > protected function getYear() { return $this->month; } protected function getYear() { return $this->month;。 ; }
  • protected function isWeekend() {
  • return $this->weekend;
  • }
  • protected function isCurrent() {
  • return $> currentdate;
  • }
  • public function getTDHref() {
  • return $this->getDay();
  • }
  • public function getTD() {
  • $class = '';
  • $td = "td";
  • if ($this->isCurrent()) {
  • $class = '今天';
  • }
  • $this-> ;retunrhtml .= "" 。 $class = '';
  • $td = "td";
  • if ($ this->isCurrent()) {
  • $class = '今天';
  • }
  • $this- >retunrhtml .= "" 。 $month) {
  • $this->makeWeeks($year, $month);
  • $this->getCalendarHeader();
  • for ($i = 0; $i 週); $i ) {
  • $this->getBeginTR();
  • for ($j = 0; $j
  • if (!empty($this ->週[$i][$j])) {
  • $this->day = $this->week[$i][$j];
  • $this->currentdate = 0;
  • if ($this->year == date(' Y') && $this->month == date('m') && $this->day == date('j')) {
  • $ this->目前日期= 1;
  • }
  • if ($j == 5 || $j == 6) {
  • $this->weekend = 1;
  • $this->getTDWeekend ( );
  • }
  • else {
  • $this->weekend = 0;
  • $this->getTD();
  • }
  • }
  • else {
  • $this-> ;retunrhtml .= "
  • ";
  • }
  • }
  • $this->getEndTR();
  • }
  • $ this ->getCalendarFooter();
  • }
  • public function getCodeMonth() {
  • $this->makeCodeMonth($this->year, $this->month);
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return
  • return retunrhtml;
  • }
  • public function showCodeMonth() {
  • echo $this->getCodeMonth();
  • }
  • }
  • }}} > class TechCalendarForm extends CalendarForm { public function getTDHref() {
    使用範例:
    $cal = new CalendarForm(2012, 5);
    $cal->showCodeMonth();
    1. class CalendarForm {
    2. protected $year;
    3. protected $month;
    4. protected day;
    5. protected $month;
    6. protectedday $ 受保護的$currentdate;
    7. 受保護的$dayofmonth;
    8. 受保護的$day_count;
    9. 受保護的$num;
    10. 受保護的$week = array() ;
    11. 受保護的$retunrhtml = " " ;
    12. function __construct($year, $month) {
    13. $this->makeWeeks($year, $month);
    14. }
    15. public function setYearMonth($年, $month) {
    16. $this->year = $year;
    17. $this->month = $month;
    18. }
    19. 內部函數resetDayCount() {
    20. $this- >day_count = 1;
    21. }
    22. 創函數setFirstWeek() {
    23. $this->num = 0;
    24. }
    25. 公用函數getDayOfMonth($year, $月) {
    26. $this->resetDayCount();
    27. 回傳日期('t', mktime(0, 0, 0, $month, $this- >day_count, $年));
    28. }
    29. 陰道函數setDayOfMonth($year, $month) {
    30. $this->dayofmonth = $this->getDayOfMonth($year, $month) ;
    31. }
    32. private function getDayOfWeek() {
    33. return date('w', mktime(0, 0, 0, $this->month, $this->day_count, $this- >year));
    34. }
    35. public function getNextMonth() {
    36. return date('m', mktime(0, 0, 0, $this->month, 28, $今年- >年) 432000);
    37. }
    38. public function getNextYear() {
    39. return date('Y', mktime(0, 0, 0, $this->月, 28, $this ->year) 432000);
    40. }
    41. public function getPrevMonth() {
    42. return date('m', mktime(0, 0, 0, $this-> ;月, 1, $今年->年) - 432000);
    43. }
    44. public function getPrevYear() {
    45. return date('Y', mktime(0, 0, 0, $this->月, 1, $this->年) - 432000);
    46. }
    47. 蒸發函數makeWeeks($year, $month) {
    48. $this->setYearMonth($year, $
    49. $this->setYearMonth($year, $
    50. $this->setYearMonth($year, $
    51. $this->setYearMonth($year, $
    52. $this->setYearMonth($year, $
    53. $this->setYearMonth($year, $ $this->setDayOfMonth($今年->年,$這個->月);
    54. $this->setFirstWeek();
    55. $this->num = 0;
    56. for ($i = 0; $i $dayofweek = $this->getDayOfWeek();
    57. $dayofweek = $dayofweek - 1;
    58. if ($dayofweek == -1) {
    59. $dayofweek = 6 ;
    60. }
    61. if ($dayofweek == $i) {
    62. $this->week[$this->num][$i] = $this->day_count;
    63. $this->day_count ;
    64. }
    65. else {
    66. $this->week[$this->num][$i] = "";
    67. }
    68. }
    69. while (TRUE) {
    70. $this->num ;
    71. for ($i = 0; $i $this->week[$this->num][$ i] = $this->day_count;
    72. $this->day_count ;
    73. if ($this->day_count > $this->dayofmonth) {
    74. 中斷;
    75. }
    76. }
    77. if ($this->day_count > $this->dayofmonth) {
    78. 線;
    79. }
    80. }
    81. }
    82. public function getCalendarHeader() {
    83. public function getCalendarHeader() {
    84. > 🎜> $this->retunrhtml =
    85. "" .
    86. 」 .
    87. "
    88. " .
    89. "
    90. " .
    91. "
    92. " .
    93. "
    94. " .
    95. "
    96. " .
    97. "
    98. " .
    99. "星期六" .
    100. "
    101. " .
    102. "
    103. ";
    104. }
    105. public function getCalendarFooter() {
    106. $this->retunrhtml .= "
    107. " 。 $this->month 。 ;">週一星期二 星期二 星期三 星期四 星期五 週日
      ";
    108. }
    109. public function getBeginTR() {
    110. $this-> retunrhtml .= "
    if ($this->isWeekend()) { $font = "";
    $font = "";
    }
    else {
    $font = "";
    }
    return "" 。 $字體。父級::getDay() 。 "
    "; }} 複製程式碼
    陳述:
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
    上一篇:MySQL的備份下一篇:MySQL的備份