Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /543/zjM/index.php on line 17
我试的没错,你再试试
<?php class Car { private $speed = 0; public function getSpeed() { return $this->speed; } protected function speedUp() { $this->speed += 10; } //增加start方法,使他能够调用受保护的方法speedUp实现加速10 public function start(){ $this->speedUp(); } } $car = new Car(); $car->start(); echo $car->getSpeed();
一般这种情况都是分号!