PHP Trainer: Calendar (simple code and easy extension)
I wrote a calendar program, focusing only on functions and Implementation ideas, so the code and functions are simple, but it is easier to understand and expand.
The show () function is used to display the calendar. You can modify the show () function to display different years by passing values.
'; Echo''. $ Year.'-'. $ month .''; Echo'SundayMondayTuesdayWednesdayThursdayFridaySaturday'; // Obtain the number of days in the current month $ yearMonth =' $ year. "-". $ month '; $ monthNum = $ this-> getMonthNum ($ yearMonth); // get the day of the week on the first day of the current month $ 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 ''. $. '';} else {echo ''. $. '';} echo''; If ($ I % 7 = 0) {// change the echo line for every 7 columns output'';} Echo'';}}$ Calendar = new Calendar (); $ calendar-> show ();
:
Use of the PHP date () function
Here is a detailed description of the date () function: http://wenku.baidu.com/link? Url = OPDGzaCMWgjDE0ya8QlDbLIXX0c11ohUjsoLyRm-cYp7lz-O_7H4XBILv8JfomhbnSxXSW0FhqxYBK0_gn8Nr77XMWp-_ st7v8AYecbNZjG