I have seen some code like below, and it is strange that the __get method has been called twice, why?
class Foo {
private $bar;
function __get($name){
echo "__get is called!";
return $this->$name;
}
function __unset($name){
unset($this->$name);
}
}
$foo = new Foo;
unset($foo->bar);
echo $foo->bar;
Attention: unset($foo->bar) will not call the __get.
For me, it looks like a bug. Put some debugging code (the following) and see the result:
The result is: