Simple existence of PHP (one of the magic methods: Fault tolerance)
name = $name; $this->age = $age;} Get Magic Method # @param string $namepublic function __get ($param) {//return $this-$param; #允许被访问的属性 $allow = Array (' age '); if (In_array ($param, $allow)) {return $this $param;}} __set () Sets the Magic method # @param string $name #param string $valpublic function __set ($name, $val) {$allow = array (' Age ', ' money '); F (In_array ($name, $allow)) {$this, $name = $val;}} __isset () Decision data public Function __isset ($name) {return isset ($this-$name);} __unset destroy data Public function __unset ($name) {//build unset list $allow =array (' tail '); if (In_array ($name, $allow)) {echo ' Unset running '; unset ($this-$name);}} Instantiate $p = new person (' ZP ', +), $p->age = 200;echo $p->money = 200000000; $p->tail = "a"; Var_dump (Isset ($p name); Var_dump (Isset ($p->age)); Var_dump (Isset ($money));//Var_dump (Empty ($tail)); unset ($p->tail);//Var_ Dump ($tail);
http://www.bkjia.com/PHPjc/969599.html www.bkjia.com true http://www.bkjia.com/PHPjc/969599.html techarticle php Simple Existence (Magic method of Action: fault tolerance) name = $name; $this->age = $age;} Get Magic Method # @param string $namepublic function __get ($param) {//return $this-$p ...