PHP Design Calendar Class One (38)

Source: Internet
Author: User
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 yearPrivate$month;//the current monthPrivate$start _weekday;//The first day of the month corresponds to the weekPrivate$days;//The current month altogether how many daysfunction __construct () {$ This->year=isset ($_get[" Year"]) ? $_get[" Year"]: Date ("Y"); $ This->m> "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}&m/span>"; } Privatefunction Prevmonth ($year, $month) {if($month = =1) {$year= $year-1; if($year <1970) $year=1970; $month= A; }Else{$month--; } return"year={$year}&m/span>"; } Privatefunction Nextyear ($year, $month) {$year= $year +1; if($year >2038) $year=2038; return"year={$year}&m/span>"; } Private function Nextmonth ($year, $month) { if($m >12) {$year++; if($year >2038) $year=2038; $month=1; }Else{$month++; } return"year={$year}&m/span>"; } 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:

The above describes the PHP design calendar class One (38), including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

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