这个是测试文件
<style>
    table 
    {
     border:1px solid #050;
}
    .fontb
    {
     color:white;
     background:blue;
}
    th{
     width:30px;
}
    th,td
    {
     height:30px;
     text-align:center;
}
</style>
<?php
//测试日历类得文件
    include 'calendar.class.php';
    $calendar=new Calender();
    $calendar->out();
    ?>
这个是类文件
<?php
    class Calender
    {
     private $year;//当前的年
     private $month;//当前的月
     private $start_weekday;//当月的第一天对应的是周几
        private $days;//当前月一共有几天
     function __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->yesr));//获取当前年当前月一共有多少天
     }
     function out() //做一个输出方法
     {
     echo '<table align="center">';
     $this->changeDate();
     $this->weeksList();//调用自己里面得方法来输出星期
         $this->daysList();
     echo '</table>';
     }
     private function weeksList()//做一个星期列表来,显示周一到周日时间
     {
     $week=array('日','一','二','三','四','五','六');//用数组来存放星期
     echo '<tr>';
     for($i=0;$i<count($week);$i++)
     echo '<th class="fontb">'.$week[$i].'</th>';//输出星期几
     echo '<tr>';
     }
     private function daysList()//天的列表,来显示当天到的日期
     {
     echo '<tr>';
     //输出空格(就是当前一月前面要空出来)
     //echo '<td>'.date("m").'</td>';
     for($j=0; $j<$this->start_weekday; $j++)//输出空格,就是几号对应星期前有几个空格
    echo '<td>&nbsp;</td>';
    for($k=1;$k<=$this->days;$k++)//获取这一月的天数
    {
     $j++;//来获取尾部的空格
     if($k==date('d'))
       echo '<td class="fontb">'.$k.'</td>';
    else
     echo '<td>'.$k.'</td>';
     if($j%7==0)
     echo '</tr><tr>';
    
    }
     echo '</tr>';
     } 
     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=12;
     }
     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==12)
     {
     $year=$year+1;
     if($year>2038)
         $year=2038;
         $month=1;
     }
     else
     {
     $month++;
     }
     return "year={$year}&month{$month}";
     }
     private function changeDate()//在头部输出当前的年月
     {
     echo '<tr>';
     echo '<td><a href="?'.$this->prevYear($this->year, $this->month).'">'.'<<'.'</td>';
     echo '<td><a href="?'.$this->prevMonth($this->year,$this->month).'">'.'<'.'</td>';
     echo '<td colspan="3">'.$this->year.'年'.$this->month.'月'.'</td>';
     echo '<td><a href="?'.$this->nextYear($this->year,$this->month).'">'.'>>'.'</td>';
     echo '<td><a href="?'.$this->nextMonth($this->year,$this->month).'">'.'>'.'</td>';
     echo '</tr>';
     }
    }
    ?>
点击上一月或者下一月的时候没有效果,不像点击上一年下一年那样。