php 构造函数 __construct,

__construct()

构造函数传递参数,并影响对象。对象产生时,自动执行。

析构函数 __destruct() 对象销毁时自动执行。

class human{

public $name;

public $age;

public function __construct($name,$age){

this->name=$name;

thiw->age=$age;

}

$a=new human (张山,28);