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);

 

posted @ 2017-02-20 22:59  在下刘彦直  阅读(2276)  评论(0编辑  收藏  举报