Strange: I know where the bug is, but I don't know why it happened? PHPcode & lt ;? Phpclasscalendar {private $ year; private $ month; pr is very strange. I know where the bug is, but I don't know why it occurs?
PHP code
Year = isset ($ _ GET ["year"])? $ _ GET ["year"]: date ("Y"); $ this-> month = isset ($ _ GET ["month"])? $ _ GET ["month"]: date ("n"); $ this-> daynum = date ("t", mktime (0, 0, 0, $ this-> month, 1, $ this-> year); $ this-> start_day = date ("w", mktime (0, 0, 0, $ this-> month, 1, $ this-> year);} function out () {echo'
'; $ This-> changecalendar (); $ this-> daylist (); $ this-> formset (); echo'
';} Function daylist () {$ day = array ('day', 'yi', '2', '3', '4', '5 ', '6', '7'); echo''; For ($ I = 0; $ I <7; $ I ++) {echo''; Echo $ day [$ I]; echo'';} Echo'';} Function formset () {echo''; For ($ j = 0; $ j <$ this-> start_day; $ j ++) echo' '; $ K = $ this-> start_day; for ($ j = 1; $ j <= $ this-> daynum; $ j ++) {if ($ j = date ("j") {echo''. $ J .'';} Else {echo''. $ J .'';} $ K ++; if ($ k % 7 = 0) echo'';}} Private function changecalendar () {echo''; // This Normal echo'PrevYear ($ this-> year, $ this-> month). '">'. '<'.''; // Abnormal echo'PreYear (). '">'. '<'.''; Echo''. $ This-> year.'-'. $ this-> month .''; Echo'';} Private function prevYear ($ year, $ month) {$ year = $ year-1; if ($ year <1970) $ year = 1970; return "year = {$ year} & month = {$ month}";} private function preYear () {$ this-> year = $ this-> year-1; if ($ this-> year <1970) {$ this-> year = 1970 ;} return "year = {$ this-> year} & month = {$ this-> month}";} private function preMonth () {if ($ this-> month = 1) {$ this-> year = $ this-> year-1; $ this-> month = 12 ;} else {$ this-> month = $ this-> month-1;} echo "111"; return 'Year = '. $ this-> year. '& month = '. $ this-> month;} private function nextYear () {$ this-> year = $ this-> year + 1; if ($ this-> year> 2038) {$ this-> year = 2038;} return 'Year = '. $ this-> year. '& month = '. $ this-> month;} private function nextMonth () {if ($ this-> month = 12) {$ this-> month = 1; $ this-> year = $ this-> year + 1;} else {$ this-> month = $ this-> month + 1;} return 'Year = '. $ this-> year. '& month = '. $ this-> month ;}}