2012-05-18 3 views
1

다음 코드가 있습니다. 엄격한 표준 : 빈 값에서 기본 객체 만들기

Strict standards: Creating default object from empty value

가 어떻게 그 고칠 수 :

 public function get_users_theme($uid) 
      { 
        $r = $this->db2->query('SELECT * FROM users_theme WHERE user_id="'.$uid.'" LIMIT 1', FALSE); 
        if ($this->db2->num_rows($r) > 0) { 
          $o->user_theme = new stdClass(); 
          $ut = $this->db2->fetch_object($r); 
          foreach($ut as $l=>$s) { 
            $o->user_theme->$l = stripslashes($s); 
      } 
          return $o->user_theme; 
        } else { 
          return FALSE; 
        } 
      } 

그 라인 5는 다음과 같은 오류를 생산하고 있습니다 나타 납니까?

감사

+1

가능한 복제본 [PHP Strict 표준 : 빈 값에서 기본 객체 만들기 - 수정 방법?] (http://stackoverflow.com/questions/1949966/php-strict-standards-creating-default-object-from- empty-value-to-fix) –

답변

4

당신이 객체로 사용하기 시작하면 $o이 때문에 단지 stdClass의 사전 객체를 만들 선언되지 않았습니다

$o = new stdClass(); 
$o->user_theme = new stdClass(); 

또는 더 나은, 그 어디에서나 $o->user_theme 교체 function with $user_theme - 코드에 특수한 객체가 필요하지 않은 것 같기 때문에 일반적인 변수로 충분합니다.

관련 문제