PHP Trainer: Calendar (simple code and easy extension)

Source: Internet
Author: User

PHP Trainer: Calendar (simple code and easy extension)

I wrote a calendar program, focusing only on functions and Implementation ideas, so the code and functions are simple, but it is easier to understand and expand.

The show () function is used to display the calendar. You can modify the show () function to display different years by passing values.

 '; Echo''. $ Year.'-'. $ month .''; Echo'SundayMondayTuesdayWednesdayThursdayFridaySaturday'; // Obtain the number of days in the current month $ yearMonth =' $ year. "-". $ month '; $ monthNum = $ this-> getMonthNum ($ yearMonth); // get the day of the week on the first day of the current month $ this-> firstDay = $ year. "-". $ month. "-01"; $ this-> firstNum = $ this-> getWeek ($ this-> firstDay ); $ this-> firstDayNum = $ this-> weekarray [$ this-> firstNum]; echo''; For ($ I = 1; $ I <= $ monthNum + ($ this-> firstNum); $ I ++) {echo''; If ($ I >=$ this-> firstNum + 1) {$ a = $ I-$ this-> firstNum; if ($ a = $ day) {echo ''. $. '';} else {echo ''. $. '';} echo''; If ($ I % 7 = 0) {// change the echo line for every 7 columns output'';} Echo'';}}$ Calendar = new Calendar (); $ calendar-> show ();

:

Use of the PHP date () function

Here is a detailed description of the date () function: http://wenku.baidu.com/link? Url = OPDGzaCMWgjDE0ya8QlDbLIXX0c11ohUjsoLyRm-cYp7lz-O_7H4XBILv8JfomhbnSxXSW0FhqxYBK0_gn8Nr77XMWp-_ st7v8AYecbNZjG

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.