<?php class Car{ //在这里定义一个共有属性name public $name; //正确 //正确-->默认public属性 //var $name; //$name protected $color; //public可有可无 public function setcolor($c) { $this->color = $c; } } $car = new Car(); //在这里输出$car对象的name属性 $car->name = '凯迪拉克';
<?php class Car{ //在这里定义一个共有属性name public $name; //正确 //正确-->默认public属性 //var $name; //$name protected $color; //public可有可无 public function setcolor($c) { $this->color = $c; } } $car = new Car(); //在这里输出$car对象的name属性 $car->name = '凯迪拉克';
2014-07-12
举报