class Calendar{
protected $_table1;//table表格
/*
* 根据日期获取一周的日期
*/
public function showOneWeek()
{
$week='2015-04-28';
$whichD=date('w',strtotime($week));
$weeks=array();
for($i=0;$i<7;$i++){
if($i
$date=strtotime($week)-($whichD-$i)*24*3600;
}else{
$date=strtotime($week)+($i-$whichD)*24*3600;
}
$weeks[$i]=date('Y-m-d',$date);
}
$this->_table1="
$this->_table1.="
";foreach($weeks as $k=>$v){
$i=date('d',strtotime($v));
$this->_table1.="
$i
";
}
$this->_table1.="
";echo $this->_table1;
}
/**
* 输出日历
*/
public function showCalendar()
{
echo $this->_table;
}
}
$calc=new Calendar();
$calc->showOneWeek();