创建类的时候var和public的区别
<?php class Car { var $name = '汽车'; function getName(){ return $this->name; } } $car =new Car(); $car->name="奥迪A6"; echo $car->getName(); ?> <?php class Car { public $name = '汽车'; public function getName(){ return $this->name; } } $car =new Car(); $car->name="奥迪A6"; echo $car->getName(); ?>