 
		北国风光
2015-06-06 13:19
 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(); 
				一般这种情况都是分号!
PHP进阶篇
181961 学习 · 2668 问题
相似问题