getMaximumSpeed();//150 echo ''; class Street extends FastCar {protected $speedLimit;protected $cars; public function __construct($speedLimit = 200) {$this->cars = array(); //初始化变量$this->speedLimit = $speedLimit;} function isStreetLegal($car) {if($car instanceof ISpeedInfo) {if($car->getMaximumSpeed() < $this->speedLimit) {return true;} else {return false;}} else {//扩展类必须实现ISpeedInfo才能使street合法return false;}} public function addCar($car) {if($this->isStreeLegal($car)) {echo 'The Car was allowed on the road.';$this->cars[] = $car;} else {echo 'The Car is too fast and was not allowed on the road.';}} } /* class Street extends FastCar{} */ $a = new Street(); echo $a->getMaximumSpeed(); //150