Time to write a calendar program, only pay attention to the function and implementation of the idea, so the code and function are relatively simple, but understanding and expansion is also relatively easy.
Show () function to display the calendar, you can modify the show () function, by passing the value of the way to display different years.
-->'; Echo ''. $year. '-'. $month. ''; Echo 'SundayMondayTuesdayWednesdayThursdayFridaySaturday'; How many days $yearMonth = ' $year ' to get the current month.
-". $month ';
$monthNum = $this->getmonthnum ($yearMonth); The first day of the current month is the week $this->firstday = $year. -". $month."
-01 ";
$this->firstnum = $this->getweek ($this->firstday);
$this->firstdaynum = $this->weekarray[$this->firstnum]; Echo ''; For ($i =1 $i <= $monthNum + ($this->firstnum); $i + +) {echo '';
if ($i >= $this->firstnum+1) {$a = $i-$this->firstnum;
if ($a = = $day) {echo '. $a. ';
}else{echo '. $a. '; } Echo ''; if ($i%7 = = 0) {//7 columns per output for one line of Echo ''; } Echo '';
}} $calendar = new calendar (); $calendar->show ();
Effect Chart:
Use of the PHP date () function
Here is a detailed explanation of the date () function: http://wenku.baidu.com/link?url=OPDGzaCMWgjDE0ya8QlDbLIXX0c11ohUjsoLyRm-cYp7lz-O_ 7h4xbilv8jfomhbnsxxsw0fhqxybk0_gn8nr77xmwp-_st7v8ayecbnzjg