构造函数是这样写的吗?
还有一些疑问
class car{
public $name="jordan";//引号内的是默认值吗?
public $height="198";
public $weight="98";
function __construct($name,$height,$weight) {
//在对象实例化时自动调用
}
$this->name=$name;//为什么要重新设置变量,上面的public $name不是变量吗?如果不是变量为什么要加上$
$this->height=$height;//为什么$this->name而不是$this->$name?
$this->weight=$weight;
//定义方法
public function f{
echo "名字:".$this->name.",身高:".$this->height.",体重:".$this->weight."<br />";
}
$b = new $car(abc,100;200);
echo $b->name;
echo $b->height;
echo $b->weight;
echo $b->f;
//先输出function f,接着依次输出$name $height $weight,再输出一次 function f,是这个顺序吗?