0
$this->user->settings
의 복제본을 $this->updateUser
에 전달하여 원래 배열에 영향을 미치지 않습니다.PHP - 객체 복제
private function updateSettings($field, $value)
{
echo gettype($this->user->settings); // array
$this->user->settings[$field] = $value;
$this->updateUser('settings', json_encode($this->user->settings));
echo gettype($this->user->settings); // string
}
어떻게 수행 할 수 있습니까?
개체 복제가 필요한 경우 clone 키워드를 사용하여 개체 복제 –
키워드 clone은 어떤 이유로 스크립트를 중지합니다. –