Php calendar
Year = date ('Y'); $ this-> month = date ('M'); $ this-> val = $ val; $ vars = get_class_vars (get_class ($ this); foreach ($ options as $ key => $ value) {if (array_key_exists ($ key, $ vars )) {$ this-> $ key = $ value ;}} function display () {$ value. ='
'; $ Value. = $ this-> showChangeDate (); $ value. = $ this-> showWeeks (); $ value. = $ this-> showDays ($ this-> year, $ this-> month); $ value. ='
'; Return $ value;} private function showWeeks () {$ value. =''; Foreach ($ this-> weeks as $ title) {$ value. =''. $ Title .'';} $ Value. =''; Return $ value;} private function showDays ($ year, $ month) {$ nowtime = mktime (0, 0, 0, $ month, 1, $ year ); // converted to seconds on the first day of the current month $ daysofmonth = date (t, $ nowtime); // The number of days of the current month $ weekofbeginday = date (w, $ nowtime ); // The first day of the month is the day of the week $ weekofendday = date (w, mktime (, 0, $ month +, $ year )); // the last day of the month is the day of the week $ daysofprevmonth = date (t, mktime (, 0, $ month, 0, $ year); // The number of days in the previous month $ count = 1; // count // list the days after the previous month for ($ I = 1; $ I <= $ weekofbeginday; $ I ++) {$ value. ="". ($ Daysofprevmonth-$ weekofbeginday + $ I ).""; $ Count ++;} // All for ($ I = 1; $ I <= $ daysofmonth; $ I ++) {$ css = ($ count % 7 = 0 | $ count % 7 = 1 )? "Weekday": "normalday"; if ($ I = $ today) $ css. = "today"; $ value. ="". $ I .""; If ($ count % 7 = 0) $ value. =""; $ Count ++;} // for ($ I = 1; $ I <= 6-$ weekofendday; $ I ++) {$ value. ="". $ I ."";} $ Value. =''; Return $ value;} private function showChangeDate () {$ url = basename ($ _ SERVER ['php _ SELF']); $ value =''; $ Value. ='PreYearUrl ($ this-> year, $ this-> month). '">'. 'last year '.''; $ Value. ='PreMonthUrl ($ this-> year, $ this-> month). '">'. 'last month '.''; $ Value. =''; $ Value. ='NextMonthUrl ($ this-> year, $ this-> month). '">'. 'next month '.''; $ Value. ='NextYearUrl ($ this-> year, $ this-> month). '">'. 'next year '.''; $ Value. =''; Return $ value;} private function preYearUrl ($ year, $ month) {$ year = ($ this-> year <= 1970 )? 1970: $ year-1; return 'Year = '. $ year. '& month = '. $ month;} private function nextYearUrl ($ year, $ month) {$ year = ($ year >= 2038 )? 2038: $ year + 1; return 'Year = '. $ year. '& month = '. $ month;} private function preMonthUrl ($ year, $ month) {if ($ month = 1) {$ month = 12; $ year = ($ year <= 1970 )? 1970: $ year-1;} else {$ month --;} return 'Year = '. $ year. '& month = '. $ month;} private function nextMonthUrl ($ year, $ month) {if ($ month = 12) {$ month = 1; $ year = ($ year> = 2038 )? 2038: $ year + 1;} else {$ month + +;} return 'Year = '. $ year.' & month = '. $ month ;}}
$ Year, 'month' => $ month); if (isset ($ _ GET ['Year']) & isset ($ _ GET ['month']) {$ params = array ('year' = >$ _ GET ['Year'], 'month' = >$ _ GET ['month']); $ year = $ _ GET ['Year']; $ month = $ _ GET ['month'];} $ cal = new Calendar ($ params, $ list_sign ); echo $ cal-> display ();?>