PHP Design Calendar Class One (38)

Source: Internet
Author: User
PHP Design Calendar Class One (38)

Consists of two files:

The first of the test.php

 
  PHP    "calendar.class.php";    $calendar=new  calendar;    $calendar-out ();

Second Calendar class: calendar.class.php

 PhpclassCalendar {Private$year;//the current year        Private$month;//the current month        Private$start _weekday;//The first day of the month corresponds to the week        Private$days;//The current month altogether how many daysfunction __construct () {$ This->year=isset ($_get[" Year"]) ? $_get[" Year"]: Date ("Y"); $ This->month=isset ($_get["Month"]) ? $_get["Month"]: Date ("m"); $ This->start_weekday=date ("W", Mktime (0,0,0, $ This->month,1, $ This-Year )); $ This->days=date ("T", Mktime (0,0,0, $ This->month,1, $ This-Year )); } function out() {echo'';            $this"test.php");            $thisweekslist ();            $thisdayslist (); echo  '
 
   
 
  
    ->chagedate (->->
   
 
'; } Privatefunction Weekslist () {$week=array ('Day','a','two','three','Four','Five','Six'); Echo''; for($i =0; $i ) echo ' '. $week [$i]. ' ' ; Echo ' ' ; } Private function Dayslist () {echo ' ' ; // output Space (the first day of the current January will be empty) for($j = 0; $j <$ This->start_weekday; $j + + ) echo ' ' ; for($k = 1; $k <=$ This->days; $k + + ) {$j++ ; if($k ==date ( ' D ' )) echo ' '. $k. ' ' ; Else Echo ' '. $k. ' ' ; if($j% 7== 0 ) echo ' ' ; } // several spaces behind while($j% 7!== 0 ) {echo ' ' ; $j++ ; } Echo ' ' ; } Private function Prevyear ($year, $month) {$year= $year- 1 ; if($year < 1970 ) $year= 1970 ; return " year={$year}&month={$month} " ; } Private function Prevmonth ($year, $month) { if($month = = 1 ) {$year= $year- 1 ; if($year < 1970 ) $year= 1970 ; $month= A ; } Else {$month-- ; } return " year={$year}&month={$month} " ; } Private function Nextyear ($year, $month) {$year= $year + 1 ; if($year > 2038 ) $year= 2038 ; return " year={$year}&month={$month} " ; } Private function Nextmonth ($year, $month) { if($month = = A ) {$year++ ; if($year > 2038 ) $year= 2038 ; $month= 1 ; } Else {$month++ ; } return " year={$year}&month={$month} " ; } Privatefunction Chagedate ($url = "" ) {echo ' ' ; Echo ' '.$ This->prevyear ($ This->year, $ This->month).'">'.'<<'.''; Echo''.$ This->prevmonth ($ This->year, $ This->month).'">'.'<'.''; Echo''; Echo''; Echo''; Echo''.$ This->nextyear ($ This->year, $ This->month).'">'.'>>'.''; Echo' '. $ this->nextmonth ($this->year, $this->month). ' "> '. ' > '. ' '; Echo ';}}

Effect:

  • 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.