Will isset() trigger __get and why?

前端 未结 5 1752
面向向阳花
面向向阳花 2021-01-02 05:33
class a {
   function __get($property){...}
}

$obj = new a();
var_dump(isset($obj->newproperty));

Seems the answer is nope but why?

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-02 06:10

    The magic function __get is only called when you try to access a property that doesn't exist. Checking whether a property exists is not the same as retrieving it.

提交回复
热议问题