클래스 속성의 가치 이전 문제에 대해 조언을 구하고 싶습니다.
class selectCondition
{
private $intervalNum;
private $arrayParameter;
private $DateInterval;
private $startDate;
private $EndDate;
function __construct($intervalNum,$unit,$EndDate='',$conditionName=[],$arrayParameter=[])
{
$this->intervalNum=$intervalNum;
$this->DateInterval='P'.$intervalNum.$unit;
$this->EndDate=new DateTime();
if($EndDate!=''){
$arydate=explode('-', $EndDate);
$this->EndDate=$this->EndDate->setDate($arydate[0],$arydate[1],$arydate[2]);
}
$this->startDate=$this->EndDate;
$this->startDate=$this->startDate->sub(new DateInterval($this->DateInterval));
}
public function dateRange()
{
return $this->startDate->format('Y-m-d').'至'.$this->EndDate->format('Y-m-d'); }
/*
$today=new selectCondition(3,'D');$today->dateRange();
输出结果:2019-12-06至2019-12-06
为什么不是2019-12-06至2019-12-09
属性间是地址传递?该怎么解决?谢谢
*/