PHP practiced hand: Calendar (code simple, easy to expand) _php Tutorial

Source: Internet
Author: User

PHP practiced hand: Calendar (code simple, easy to expand)


Time to write a calendar program, only focus on the function and implementation of ideas, so the code and functions are relatively simple, but understanding and extension is easier.

The show () function is used to display the calendar, and you can modify the show () function to display a different date by passing a value.

 '; Echo ''. $year. '-' $month. ''; Echo 'SundayMondayTuesdayWednesdayThursdayFridaySaturday'; The number of days to get the current month $yearMonth = ' $year. '            -". $month";            $monthNum = $this->getmonthnum ($yearMonth); Get the first day of the current month is the days of the week $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 '. $a. ';                        }else{echo '. $a. '; }} Echo ''; if ($i%7 = = 0) {//Each output 7 columns will be replaced by a line of Echo ''; }} Echo '';    }} $calendar = new calendar (); $calendar->show ();


Use of the PHP date () function

Here is an explanation of the date () function: http://wenku.baidu.com/link?url=OPDGzaCMWgjDE0ya8QlDbLIXX0c11ohUjsoLyRm-cYp7lz-O_ 7h4xbilv8jfomhbnsxxsw0fhqxybk0_gn8nr77xmwp-_st7v8ayecbnzjg

http://www.bkjia.com/PHPjc/847853.html www.bkjia.com true http://www.bkjia.com/PHPjc/847853.html techarticle php practiced hand: calendar (simple code, easy to expand) time to write a calendar program, only focus on the function and implementation of ideas, so the code and functions are relatively simple, but the understanding and expansion than ...

  • Related Article

    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.