Very strange. I know where the bug is, but I don't know why it happened.

Source: Internet
Author: User
Strange: I know where the bug is, but I don't know why it happened? PHPcode & lt ;? Phpclasscalendar {private $ year; private $ month; private $ daynum; private $ start_day; very strange. I know where the bug is, but I don't know why it occurs?
PHP code
  
  Year = isset ($ _ GET ["year"])? $ _ GET ["year"]: date ("Y"); $ this-> month = isset ($ _ GET ["month"])? $ _ GET ["month"]: date ("n"); $ this-> daynum = date ("t", mktime (0, 0, 0, $ this-> month, 1, $ this-> year); $ this-> start_day = date ("w", mktime (0, 0, 0, $ this-> month, 1, $ this-> year);} function out () {echo'
  
  
   
   
'; $ This-> changecalendar (); $ this-> daylist (); $ this-> formset (); echo'
  
  
';} Function daylist () {$ day = array ('day', 'yi', '2', '3', '4', '5 ', '6', '7'); echo''; For ($ I = 0; $ I <7; $ I ++) {echo''; Echo $ day [$ I]; echo'';} Echo'';} Function formset () {echo''; For ($ j = 0; $ j <$ this-> start_day; $ j ++) echo' '; $ K = $ this-> start_day; for ($ j = 1; $ j <= $ this-> daynum; $ j ++) {if ($ j = date ("j") {echo''. $ J .'';} Else {echo''. $ J .'';} $ K ++; if ($ k % 7 = 0) echo'';}} Private function changecalendar () {echo''; // This Normal echo'PrevYear ($ this-> year, $ this-> month). '">'. '<'.''; // Abnormal echo'PreYear (). '">'. '<'.''; Echo''. $ This-> year.'-'. $ this-> month .''; Echo'';} Private function prevYear ($ year, $ month) {$ year = $ year-1; if ($ year <1970) $ year = 1970; return "year = {$ year} & month = {$ month}";} private function preYear () {$ this-> year = $ this-> year-1; if ($ this-> year <1970) {$ this-> year = 1970 ;} return "year = {$ this-> year} & month = {$ this-> month}";} private function preMonth () {if ($ this-> month = 1) {$ this-> year = $ this-> year-1; $ this-> month = 12 ;} else {$ this-> month = $ this-> month-1;} echo "111"; return 'Year = '. $ this-> year. '& month = '. $ this-> month;} private function nextYear () {$ this-> year = $ this-> year + 1; if ($ this-> year> 2038) {$ this-> year = 2038;} return 'Year = '. $ this-> year. '& month = '. $ this-> month;} private function nextMonth () {if ($ this-> month = 12) {$ this-> month = 1; $ this-> year = $ this-> year + 1;} else {$ this-> month = $ this-> month + 1;} return 'Year = '. $ this-> year. '& month = '. $ this-> month ;}}

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.