0
내가 다음과 같습니다 클래스가 있습니다존재하지 않는 메소드를 호출 할 때 __call 대신 __get이 호출되는 이유는 무엇입니까?
class MyClass
{
public __get($prop)
{
$method = 'get' . ucfirst($prop);
if (method_exists($this, $metodo))
return $this->$metodo();
if (property_exists($this, $prop))
return $this->$prop;
throw new Exception("Nonexisting property $prop");
}
public function __call($method, $args)
{
$prop = strtr($method, 'add', '');
$prop = lcfirst($prop);
if (is_array($this->$prop))
array_push($this->$prop, $args[0]);
}
}
하지만 $obj->addTags('test');
을 할 경우는 __get를 호출을, 마녀가 나에게 메시지와 함께 예외 제공 : "존재하지 않는 속성 addTags"
을 내가 뭘해야 내 __call 대신 내 __get을 호출해야합니까?
미리 감사드립니다.