year = date ( 'y' ); $this->month = date ( 'm' ); $this->val = $val; $vars = get_class_vars ( get_class ( $this ) ); foreach ( $options as $key => $value ) { if (array_key_exists ( $key, $vars )) { $this->$key = $value; } } } function display() { $value .= ''; $value .= $this->showchangedate (); $value .= $this->showweeks (); $value .= $this->showdays ( $this->year, $this->month ); $value .= '
'; return $value; } private function showweeks() { $value .= ''; foreach ( $this->weeks as $title ) { $value .= '' . $title . ''; } $value .= '
'; return $value; } private function showdays($year, $month) { $nowtime = mktime(0,0,0,$month,1,$year);//当月1号转为秒 $daysofmonth = date(t,$nowtime);//当月天数 $weekofbeginday = date(w,$nowtime);//当月第一天是星期几 $weekofendday = date(w,mktime(0,0,0,$month+1,0,$year));//当月最后一天是星期几 $daysofprevmonth = date(t,mktime(0,0,0,$month,0,$year));//上个月天数 $count = 1;//计数 //列出上月后几天 for($i = 1 ; $i <= $weekofbeginday ; $i++) { $value .= .($daysofprevmonth-$weekofbeginday+$i). ; $count++; } //当月全部 for($i = 1 ; $i month ) . '>' . '上年' . ' '; $value .= 'premonthurl ( $this->year, $this->month ) . '>' . '上月' . ' '; $value .= ''; $value .= 'month . '\'>'; for($ye = 1970; $ye year) ? 'selected' : ''; $value .= '' . $ye . ''; } $value .= ''; $value .= 'year . '&month=\'+this.options[selectedindex].value+\'\'>'; for($mo = 1; $mo month) ? 'selected' : ''; $value .= '' . $mo . ''; } $value .= ''; $value .= ' '; $value .= 'nextmonthurl ( $this->year, $this->month ) . '>' . '下月' . ' '; $value .= 'nextyearurl ( $this->year, $this->month ) . '>' . '下年' . ' '; $value .= '
'; return $value; } private function preyearurl($year, $month) { $year = ($this->year = 2038) ? 2038 : $year + 1; return 'year=' . $year . '&month=' . $month; } private function premonthurl($year, $month) { if ($month == 1) { $month = 12; $year = ($year = 2038) ? 2038 : $year + 1; } else { $month ++; } return 'year=' . $year . '&month=' . $month; }}
$year, 'month' => $month );if (isset ( $_get ['year'] ) && isset ( $_get ['month'] )) { $params = array ('year' => $_get ['year'], 'month' => $_get ['month'] ); $year = $_get ['year']; $month = $_get ['month'];}$cal = new calendar ( $params, $list_sign );echo $cal->display ();?>