글쎄요, 제 모델에 estimate.php라고 쓰여진 getDaysTotal
함수가 있습니다. 내가Yii2 : 에코 변수가 두 번 잘못 입력되었습니다.
echo $model->DaysTotal;
를 사용하는 경우 내 view.php에 내가 값을 얻는 경우에 내가 다시
echo $model->DaysTotal;
그것을 할 경우
3. 그러나 지금은 왜 내가, 어떤 생각을 1. 취득 그것을 이렇게 얻는 것. 이것은 estimate.php의 모든 함수에서 발생합니다. 두 번째로 사용하면 결과가 이상합니다.
여기에 뭐가 잘못 되었나요? 이 문제를 어떻게 해결할 수 있습니까? 감사합니다. .
public function getDaysTotal() {
$this->discharge_date = strtotime($this->discharge_date);
$this->admission_date = strtotime($this->admission_date);
$datediff = ($this->discharge_date - $this->admission_date);
$fraction_days = ($datediff/(60*60*24));
if ($fraction_days < 1){
return 1;
}elseif(($datediff)%(60*60*24) < 10800){
$option2 = floor($datediff/(60*60*24));
return $option2;
}elseif(($datediff%86400) > 10800 && ($datediff%86400)<21600) {
$option3 = ceil($datediff/(60*60*24)*2)/2;
return $option3;
}elseif (($datediff%86400) >21600){
$option4= ceil($datediff/86400);
return $option4;
}
함수 코드 geDaysTotal 게시 –
안녕하세요 @IsabelHM - 기능 코드로 질문 업데이트. – Pawan
당신은 또한'admision_date' /'discharge_date' getters를 사용합니다. 그들 중 하나가 부작용이있을 수 있습니다. –