Use PHP to generate a calendar-PHP source code

Source: Internet
Author: User
Use PHP to generate a calendar

Use PHP to generate a calendar

1. [File]Calendar. class. php
 Year = date ('Y'); $ this-> month = date ('M'); $ vars = get_class_vars (get_class ($ this )); foreach ($ options as $ key =>$ value) {if (array_key_exists ($ key, $ vars) {$ this-> $ key = $ value ;}}} function display () {echo'
 
 
  
  
'; $ This-> showChangeDate (); $ this-> showWeeks (); $ this-> showDays ($ this-> year, $ this-> month); echo'
 
 
';} Private function showWeeks () {echo''; Foreach ($ this-> weeks as $ title) {echo''. $ Title .'';} Echo'';} Private function showDays ($ year, $ month) {$ firstDay = mktime (0, 0, 0, $ month, 1, $ year ); $ starDay = date ('W', $ firstDay); $ days = date ('t', $ firstDay); echo''; For ($ I = 0; $ I <$ starDay; $ I ++) {echo' ';} For ($ j = 1; $ j <= $ days; $ j ++) {$ I ++; if ($ j = date ('D') {echo''. $ J .'';} Else {echo''. $ J .'';} If ($ I % 7 = 0) {echo'';} Echo'';} Private function showChangeDate () {$ url = basename ($ _ SERVER ['php _ SELF']); echo''; Echo'PreYearUrl ($ this-> year, $ this-> month). '">'. '<'.''; Echo'PreMonthUrl ($ this-> year, $ this-> month). '">'. '<'.''; Echo''; Echo'NextMonthUrl ($ this-> year, $ this-> month). '">'. '> '.''; Echo'NextYearUrl ($ this-> year, $ this-> month). '">'. '> '.''; Echo'';} 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 ;}}
2. [File]Demo. php
 $ _ GET ['Year'], 'month' => $ _ GET ['month'],);} $ params ['URL'] = 'demo. php '; require_once' calendar. class. php ';?>            Calendar demo        
                         

Display ();?>

3. [Image]Sample.jpg

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.