PHP practiced hand: Calendar (code simple, easy to expand)
Time to write a calendar program, only focus on the function and implementation of ideas, so the code and functions are relatively simple, but understanding and extension is easier.
The show () function is used to display the calendar, and you can modify the show () function to display a different date by passing a value.
'; Echo ''. $year. '-' $month. ''; Echo 'SundayMondayTuesdayWednesdayThursdayFridaySaturday'; The number of days to get the current month $yearMonth = ' $year. ' -". $month"; $monthNum = $this->getmonthnum ($yearMonth); Get the first day of the current month is the days of 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) {//Each output 7 columns will be replaced by a line of Echo ''; }} Echo ''; }} $calendar = new calendar (); $calendar->show ();
:
Use of the PHP date () function
Here is an explanation of the date () function: http://wenku.baidu.com/link?url=OPDGzaCMWgjDE0ya8QlDbLIXX0c11ohUjsoLyRm-cYp7lz-O_ 7h4xbilv8jfomhbnsxxsw0fhqxybk0_gn8nr77xmwp-_st7v8ayecbnzjg
http://www.bkjia.com/PHPjc/847853.html www.bkjia.com true http://www.bkjia.com/PHPjc/847853.html techarticle php practiced hand: calendar (simple code, easy to expand) time to write a calendar program, only focus on the function and implementation of ideas, so the code and functions are relatively simple, but the understanding and expansion than ...