: This article mainly introduces the PHP design calendar Class 1 (38). If you are interested in the PHP Tutorial, please refer to it. Consists of two files:
First test. php
out();
The second calendar class: calendar. class. php
Year = isset ($ _ GET ["year"])? $ _ GET ["year"]: date ("Y"); $ this-> m> "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', 'yi', '2', '3', '4', '5 ', '6'); echo''; For ($ I = 0; $ I
'. $ Week [$ I].''; Echo'';} Private function daysList () {echo''; // Output space (to be blank before the first day of October 10, January) 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'';} // The following spaces while ($ j % 7! = 0) {echo' '; $ J ++;} echo'';} Private function prevYear ($ year, $ month) {$ year = $ year-1; if ($ year <1970) $ year = 1970; return "year = {$ year} & m/span>";} private function prevMonth ($ year, $ month) {if ($ month = 1) {$ year = $ year-1; if ($ year <1970) $ year = 1970; $ month = 12;} else {$ month --;} return "year = {$ year} & m/span>";} private function nextYear ($ year, $ month) {$ year = $ year + 1; if ($ year> 2038) $ year = 2038; return "year = {$ year} & m/span>";} private function nextMonth ($ year, $ month) {if ($ m> 12) {$ year + +; if ($ year> 2038) $ year = 2038; $ month = 1;} else {$ month ++ ;} return "year = {$ year} & m/span>";} private function chageDate ($ url = "") {echo''; Echo''. $ This-> prevYear ($ this-> year, $ this-> month).' "> '.' <'.''; Echo''. $ This-> prevMonth ($ this-> year, $ this-> month).' "> '.' <'.''; Echo''; Echo ''; echo''; Echo''. $ This-> nextYear ($ this-> year, $ this-> month).' "> '.'> '.''; Echo''. $ This-> nextMonth ($ this-> year, $ this-> month).' "> '.'> '.''; Echo'';}}
Effect:
The above introduces the PHP design calendar Class 1 (38), including the content, hope to be helpful to friends who are interested in PHP tutorials.