abstract:<?php class one{ public $name; public $age; public $yearr; public function __construct($name="zhangsan",$age="na
<?php
class one{
public $name;
public $age;
public $yearr;
public function __construct($name="zhangsan",$age="nande",$year=23){
$this->name=$name;
$this->age=$age;
$this->yearr=$year;
}
}
$one=new one("张三","男",78);//创建对象时,构造函数自动执行,自认为也就相当于触发了构造函数的执行;
echo "我的名字是".$one->name."<br>";
echo "性别是".$one->age."<br>";
echo "我的年龄是".$one->yearr."<br>";
?>
Correcting teacher:西门大官人Correction time:2019-03-03 10:37:17
Teacher's summary:php在创建对象时,会自动的调用类的__construct方法。