<?php
class Car {
private static $speed = 10;
public function getSpeed() {
return self::$speed;
}
//在这里定义一个静态方法,实现速度累加10
public static function speedUp(){
return self::$speed+=10;
}
}
class Bigcar extends Car{
public static function start(){
parent::speedUp();
}
}
$car = new Car();
Car::speedUp(); //调用静态方法加速
echo $car->getSpeed(); //调用共有方法输出当前的速度值
echo "<br/>";
echo car::speedUp();
echo "<br/>";
Bigcar::start();
echo Bigcar::speedUp();
CodeManDSH