标签:
<?php class A { public function __get($p) { echo "getting $p\r\n"; if(isset($this->$p)) { return $this->$p; } if($p == ‘p1‘) { $this->$p = 456; } return $this->$p; } } $a = new A(); var_dump($a->p1); //$a->p1 = null; //重新获取$a->$p1时,不会触发__get!! unset($a->p1);//重新获取$a->$p1时,会触发__get var_dump($a->p1);
标签:
原文地址:http://www.cnblogs.com/yangyh/p/5076096.html