有没有办法覆盖同一属性的__get
递归限制。__set
我希望能够以不同于第一个条目的方式处理第二个重新进入。
此代码示例不实用,但最容易说明问题。
class Foo {
public function __set($name,$value){
print "$name entered\n";
this->$name = $value; // want it to recurse here
}
}
$a = new Foo();
$a->baz = "derp";
print $a->baz;
// should get (cannot test at the moment)
// baz entered
// derp <- you get derp because the current php implementation creates an instance variable from the second call to __set
我的互联网中断了,所以我在手机上打字,所以很可能有错别字。