calendar.class.php
Copy the Code code as follows:
Class Calendar {
Private $year; The current year
Private $month; The current month
Private $start _weekday; The first day of the month corresponds to the week
Private $days; The current month altogether how many days
function __construct () {
$this->year=isset ($_get["year"])? $_get["Year"]: Date ("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 '
'; $this->chagedate ("test.php"); $this->weekslist (); $this->dayslist (); Echo '
';
}
Private Function Weekslist () {
$week =array (' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' VI ');
Echo ';
for ($i =0; $i
Echo '. $week [$i]. ";
Echo ';
}
Private Function Dayslist () {
Echo ';
Output space (the first day of the current January will be empty)
for ($j =0; $j < $this->start_weekday; $j + +)
Echo ';
for ($k =1; $k <= $this->days; $k +) {
$j + +;
if ($k ==date (' d '))
Echo '. $k. ';
Else
Echo '. $k. ';
if ($j%7==0)
Echo ';
}
Several spaces behind
while ($j%7!==0) {
Echo ';
$j + +;
}
Echo ';
}
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) {
$year = $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}";
}
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 ';
Echo ' Prevyear ($this->year, $this->month). ' " > '. ' << '. ';
Echo ' Prevmonth ($this->year, $this->month). ' " > '. ' < '. ';
Echo ';
Echo ';
Echo ';
Echo ' Nextyear ($this->year, $this->month). ' " > '. ' >> '. ';
Echo ' Nextmonth ($this->year, $this->month). ' " > '. ' > '. ';
Echo ';
}
}
?>
test.php
Copy the Code code as follows:
Include "calendar.class.php";
$calendar =new Calendar;
$calendar->out ();
?>
http://www.bkjia.com/PHPjc/718612.html www.bkjia.com true http://www.bkjia.com/PHPjc/718612.html techarticle calendar.class.php Copy the code as follows: PHP class Calendar {private $year;//Current year private $month;//Current Month private $start _weekda Y The first day of the month corresponds to ...