2012-12-19 3 views
1

나는 동적 메소드 이름으로 내 클래스의 프로퍼티의 값을 사용해야하지만 나는 점점 오전 : 내가하고 싶은 것은를 사용하여 속성 값

Catchable fatal error: Object of class dispatcher could not be converted to string in ... 

:

class test { 
     var $objectname = "object_name"; 
     var $methodname = "method"; 

     public function test_method() { 
      require_once("some_class_file"); 
      // Here is where I am falling out: 
      $some_object = new $this->objectname(); 
      $some_object->$this->methodname(); 
     } 
} 

즉, 내 클래스의 기존 속성에서 개체 이름과 잠재적 메서드를 동적으로 설정하려고합니다.

아이디어가 있으십니까?

답변

3

오류 때문에 다음 줄의 생성되었습니다

$some_object->$this->methodname(); 

을 바꿀 :

$some_object->{$this->methodname}();