PHP design calendar Class 1 (38), Calendar 38. PHP design calendar Class 1 (38), Calendar 38 consists of two files: the first test. phpstyletable {border: 1 pxsolid #050 ;}. fontb {color: white; background: blue;} th {width: 30 PHP design calendar Class 1 (38), Calendar 38
Consists of two files:
First test. php
out();
The second calendar class: calendar. class. php
Year = isset ($ _ GET ["year"])? $ _ GET ["year"]: date ("Y"); $ this-> month = isset ($ _ GET ["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} & month = {$ month}";} private function prevMonth ($ year, $ month) {if ($ month = 1) {$ year = $ year-1; if ($ year <1970) $ year = 1970; $ month = 12;} else {$ month --;} return "year = {$ year} & month = {$ month}";} private function nextYear ($ year, $ month) {$ year = $ year + 1; if ($ year> 2038) $ year = 2038; return "year = {$ year} & month = {$ month}";} private function nextMonth ($ year, $ month) {if ($ month = 12) {$ year ++; if ($ year> 2038) $ year = 2038; $ month = 1 ;} else {$ month ++;} return "year = {$ year} & month = {$ month}";} 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:
Calendar 38 consists of two files: the first test. php style table {border: 1px solid #050 ;}. fontb {color: white; background: blue;} th {width: 30...