欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php日历

程序员文章站 2022-05-25 15:13:26
...
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 ".($daysofprevmonth-$weekofbeginday+$i).""; $count++; } //当月全部 for($i = 1 ; $i ".$i.""; if($count%7==0) $value .= ""; $count++; } //下月前几天 for ($i = 1;$i ".$i.""; } $value .= ''; return $value; } private function showChangeDate() { $url = basename ( $_SERVER ['PHP_SELF'] ); $value = ''; $value .= '' . '上年' . ''; $value .= '' . '上月' . ''; $value .= '
'; $value .= ''; $value .= ''; $value .= '
'; $value .= '' . '下月' . ''; $value .= '' . '下年' . ''; $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 ();?>
相关标签: php日历