1.__constrtuct
基本用法
<?php
class test{
function __construct(){
}
}
$stu=new test();
?>
构造方法也叫构造函数,当对象实例化的时候执行
<?php
class show{
private $name;
private $big;
public function __construct($name,$big){
$this->name=$name;
$this->big=$big;
}
public function test(){
echo "你的姓名:{$this->name}<br>";
echo "你的年龄:{$this->big}<br>";
}
}
$stu=new show('0ne',18);
$stu->test();
?>