Magic method __unset __isset __destruct

__unset Trigger timing: the destruction of objects in the external private or protected member properties when calling

    This method has one parameter: parameter is the name of the private property of members of the

__isset Trigger timing: determining an object in an external private or protected member properties when calling

    This method has one parameter, the parameter is a member of the private property name

__destruct destructor   

    Trigger timing: when the object is destroyed automatically call

<?php

class Person
{
public $name;
protected $age;
private $height;

public function __unset($name){
if($name == 'age'){
unset($this->age);
}
}

public function __set($name,$value){
if($name == 'age'){
$this->$name = $value;
}
}

public function __get($name){
if($name == 'age'){
return $this->$name;
}
}

public function __isset($name){
if($name == 'age'){
isset return (the this $ -> $ name);
}
}

public __destruct function () {
echo 'I'm going for a walk! ';
}
}

$ = New new NIU the Person ();
// the unset ($ niu-> Age);
$ niu-> Age = 100;
// echo $ niu-> Age;

var_dump (isset ($ niu-> Age) );

 

 

    

Guess you like

Origin www.cnblogs.com/rjbc/p/11391240.html