php7中构造函数和析构函数的用法
初始化对象时候,给传值进去
class Person{
public $name; public $age;
public function __construct($n,$b){
$this->name=$n;
$this->age=$b;
}
public function say(){
echo $this->age;
}
public function __destruct(){
echo '96net.com.cn';
}
}
$xm=new Person('11','22'); $xm->say();