<?php
class Car {
public $name = '汽车';
public $speed = 0;
public function getName() {
return $this->name;
}
public function speedUp(){
$this -> speed += 10;
}
}
$car = new Car();
echo $car->name;
echo "<br/>";
$car->speedUp();
echo $car->speed;
?>
为什么$this 后面的name 和 speed 不用加$符号?因为属性的原因吗?还是怎么样?
晚安sp