PHP outputs the calendar table code instance, php outputs the calendar instance _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP outputs the calendar table code instance, and php outputs the calendar instance. PHP outputs the calendar table code instance, and php outputs the calendar instance! DOCTYPEhtmlPUBLIC-W3CDTDXHTML1.0TransitionalENwww.w3.orgTRxhtml1DTDxhtml1-transitional.dtdhtmlx PHP output calendar table code instance, php output calendar instance
 Calendar<? Php $ MONTH = array ("lunar January", "January", "February", "March", "April", "May", "June", "July ", "August", "August"); $ enMONTH = array ("August", "January", "February ", "Marcy", "April", "May", "June", "July", "August", "September", "October", "November ", "December"); $ WEEK = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Saturday "); $ BACKCOLOR = array ("# FFC", "# FFF", "#9F6", "# FFC", "#6F0", "#6F6", "# F90 ", "# F06", "# F00", "# FC3", "# FF6", "# F99"); function PrintMon ($ year, $ mon) {date_default_timezone_set ("Asia/Shanghai"); global $ MONTH; global $ enMONTH; global $ WEEK; global $ BACKCOLOR; $ startdate = strtotime ("1 $ enMONTH [$ mon] $ year"); // Obtain the query year and month $ enddate = strtotime ("+ 1 month", $ startdate ); // get the start date of the next month as the end time of the calendar output $ theDate = getdate ($ startdate ); // Convert the date to the string format $ color = $ BACKCOLOR [$ mon]; // set the background color of the calendar echo ("

Success! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" html x...

"); $ Ym = $ year." year ". $ MONTH [$ mon]; echo (" "); Echo (" "); For ($ I = 0; $ I <7; $ I ++) // output the day of the week {echo (" ");} Echo (" "); $ TheWeek = $ theDate [wday]; // Determine the day of the week for ($ I = 0; $ I <6; $ I ++) {echo (" "); For ($ j = 0; $ j <7; $ j ++) {echo (" ");} Echo (" "); If ($ startdate = $ enddate) // if all dates have been output, end loop {$ I = 6 ;}} echo ("<? Php $ year = $ _ POST ['myyear']; $ month = $ _ POST ['mymonth']; if (is_numeric ($ year) & $ year> = 1970 & $ year <2038) {if (is_numeric ($ month) & $ month> = 1 & $ month <= 12) {PrintMon ($ year, $ month);} else if ($ month! = NULL) {echo ("The month is incorrect "."") ;}} Else if ($ year! = NULL) {echo ("The year is incorrect "."") ;}?>
$ Ym
"); Echo (" $ WEEK [$ I] "); echo ("
"); If ($ startdate <$ enddate & $ theWeek = $ j) // output the date to the column of the corresponding day of the week, do not exceed the current month date {$ theDay = $ theDate [mday]; echo ("$ theDay"); $ startdate = strtotime ("+ 1 day", $ startdate ); // one day before the date is moved forward $ theDate = getdate ($ startdate); // update date $ theWeek = ($ theWeek + 1) % 7; // update week} echo ("

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.