PHP trainer: Calendar (simple code, easy extension ). PHP trainer: Calendar (simple code, easy extension) has been used to write a calendar program, focusing only on functions and implementation ideas, so the code and functions are relatively simple, but understanding and extension are also better than PHP: Calendar (simple code, 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
Compile (simple code, easy extension) took the time to write a calendar program, focusing only on functions and implementation ideas, so the code and functions are relatively simple, but the understanding and expansion are also better...