Php calendar program, php calendar program _ PHP Tutorial

Source: Internet
Author: User
Php implements the calendar program, and php implements the calendar program. Php-based calendar program. php-based calendar program this article describes the calendar program implemented by php. Share it with you for your reference. The details are as follows: php determines whether $ Year and $ Month are Calendar programs implemented by php. php implements calendar programs.

This example describes the calendar program implemented by php. Share it with you for your reference. The details are as follows:

<? Php /// determine whether $ Year and $ Month are empty. if they are empty, the current date of the system is obtained, otherwise, use $ _ GET to GET $ Year = empty ($ _ GET ['Year'])? Date ("Y"): $ _ GET ["Year"]; $ Month = empty ($ _ GET ['month'])? Date ("m"): $ _ GET ["Month"]; // GET the current date /// $ Today = date ("Ymj "); //// initialization date array //// $ Maxday = array ("1", "2", "3", "4", "5", "6 ", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16 ", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26 ", "27", "28", "29", "30", "31"); $ Maxday_count = count ($ Maxday ); //// initialize the array of weeks //// $ Weekday = array ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri ", "Sat"); $ Weekday_count = count ($ Weekday); $ daynum = 0; $ space =" "; $ Col = 0; // Print the table header ///?>
 
  "; $ U2 ="
  

The running effect is as follows:

I hope this article will help you with php programming.

The example in this article describes the calendar program implemented by php. Share it with you for your reference. Php // determines whether $ Year and $ Month are...

<? Php //// print the weekly list //// while (list (, $ Weekvalue) = each ($ Weekday) echo" "; Echo" "; //// Print the date list ///// when the month is, a value is deleted from the end of the array, that is, 31 is deleted. if ($ Month = 4 or $ Month = 6 or $ Month = 9 or $ Month = 11) {array_pop ($ Maxday); $ Maxday_count --;} // first judge whether the month is February. If yes, then judge whether the year is a leap year. if yes, remove two values from the end of the array; otherwise, remove three values. if ($ Month = 2) {if ($ Year % 4 = 0) {array_pop ($ Maxday); $ Maxday_count-= 2 ;} else {array_pop ($ Maxday); $ Maxday_count-= 3 ;}} //// print the date //// while ($ daynum <$ Maxday_count) {echo" "; While (list ($ colnum, $ Dayvalue) = each ($ Maxday) {// determines the day of the week when the current date is set to $ DayWeek = date (" w ", strtotime ($ Year. "-". $ Month. "-". $ Dayvalue); // when the current date is at 1st, that is, the first day of each month, add the corresponding blank grid if ($ Dayvalue = 1) in front of it) for ($ I = 0; $ I <$ DayWeek; $ I ++) echo $ space; // print several blank grids each month $ daynum ++; // compare the printed date with the current date string. if the date is equal, the font is marked in red. if ($ Year. $ Month. $ Dayvalue = $ Today) {$ u1 ="";}Else {$ u1 =" "; $ u2 =" ";}if ($ DayWeek = 0 or $ DayWeek = 6) $ color =" red "; else $ color = "black"; echo" "; // Add 1 to the value of the day of the week. if it is a multiple of 7, wrap the line to exit this loop (line feed printing) if ($ DayWeek + 1) % 7 = 0) {$ col ++; break ;}} echo" ";}?>
1900) echo $ Year-1; else echo $ Year;?> & Amp; Month = <? Php echo $ Month?> "OnClick =" javascript: document. linked. submit (); "name =" Year "> <? Php echo $ Year?> & Amp; Month = <? Php echo $ Month?> "OnClick =" javascript: document. linked. submit (); "name =" Year ">>> & Amp; Month = <? Php if ($ Month-1> 0) if ($ Month-1 <10) echo "0 ". ($ Month-1); else echo $ Month-1; else echo $ Month;?> "OnClick =" javascript: document. linked. submit (); "name =" Month "> <? Php echo $ Month;?> & Amp; Month = <? Php if ($ Month + 1 <13) if ($ Month + 1 <10) echo "0 ". ($ Month + 1); else echo ($ Month + 1); else echo $ Month;?> "OnClick =" javascript: document. linked. submit (); "name =" Month ">>>
". $ Weekvalue ."
". $ U1. $ Dayvalue. $ u2 ."

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.