The calendar effects are shown below:
calendar.class.php
<?php class Calendar {private $year;//Current year private $month;//Current Month private $start _wee KDAY; The first day of the month corresponds to the week a few private $days; What is the total number of days of the current month function __construct () {$this->year=isset ($_get["year")? $_get["Year"]: DA
Te ("Y"); $this->month=isset ($_get["month"])?
$_get["Month"]: Date ("M");
$this->start_weekday=date ("W", Mktime (0, 0, 0, $this->month, 1, $this->year));
$this->days=date ("T", mktime (0, 0, 0, $this->month, 1, $this->year));
function out () {echo ' <table align= ' center > ';
$this->chagedate ("test.php");
$this->weekslist ();
$this->dayslist ();
Echo ' </table> ';
Private Function Weekslist () {$week =array (' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' six '); Echo ' <tr>'; For ($i =0 $i <count ($week); $i + +) echo ' <th class= ' fontb ' > '. $week [$i]. '
</th> ';
Echo ' </tr> ';
Private Function Dayslist () {echo ' <tr> '; Output spaces (to be vacated before the first day of January) for ($j =0; $j < $this->start_weekday; $j + +) echo ' <td> <
/TD> ';
For ($k =1 $k <= $this->days; $k + +) {$j + +;
if ($k ==date (' d ')) echo ' <td class= ' fontb ' > '. $k. ' </td> ';
else echo ' <td> '. $k. ' </td> ';
if ($j%7==0) echo ' </tr><tr> ';
}//Next few spaces while ($j%7!==0) {echo ' <td> </td> ';
$j + +; } Echo ' </tr>';
Private Function Prevyear ($year, $month) {$year = $year-1;
if ($year < 1970) $year = 1970;
Return "year={$year}&month={$month}"; Private Function Prevmonth ($year, $month) {if ($month = = 1) {$ye
AR = $year-1;
if ($year < 1970) $year = 1970;
$month = 12;
}else{$month--;
Return "year={$year}&month={$month}";
Private Function Nextyear ($year, $month) {$year = $year + 1;
if ($year > 2038) $year = 2038;
Return "year={$year}&month={$month}"; }//Url:http://www.bianceng.cn/webkf/php/201410/45945.htm PRivate function Nextmonth ($year, $month) {if ($month ==12) {$year + +;
if ($year > 2100) $year = 2100;
$month = 1;
}else{$month + +;
Return "year={$year}&month={$month}";
Private Function chagedate ($url = "") {echo ' <tr> '; Echo ' <td><a href= '. $this->prevyear ($this->year, $this->month). " > '. ' << '. '
</a></td> '; Echo ' <td><a href= '. $this->prevmonth ($this->year, $this->month). " > '. ' < '. '
</a></td> ';
Echo ' <td colspan= 3 ' > ';
Echo ' <form> '; Echo ' <select name= ' year ' onchange= ' window.location=\ '. $url. Year=\ ' +this.options[selectedindex].value+\ ' &month= '. $this->month. '
\ ' > '; For($sy =1970; $sy <= 2100; $sy + +) {$selected = ($sy = = $this->year)?
"Selected": ""; Echo ' <option '. $selected. ' value= '. $sy. ' " > '. $sy. '
</option> ';
Echo ' </select> '; Echo ' <select name= ' month ' onchange= ' window.location=\ '. $url. ' Year= '. $this->year. '
&month=\ ' +this.options[selectedindex].value ' > '; For ($sm =1 $sm <=12; $sm + +) {$selected 1 = ($sm = = $this->month)?
"Selected": "";
Echo ' <option '. $selected 1. ' value= '. $sm. ' > ' $sm. ' </option> ';
Echo ' </select> ';
Echo ' </form> ';
Echo ' </td> '; Echo ' <td><a href= '. $this->nextyear ($this->year, $this->month). " > '. ' >> '. '
</a></td> '; Echo ' <td><a href= '. $this->nextmonth ($this->year, $this->month). ' " > '. ' > '. '
</a></td> ';
Echo ' </tr> '; }}?>
test.php