<?php
class Car {
public $speed = 0; //汽车的起始速度是0
public function speedUp() {
$this->speed += 10;
return $this->speed;
}
}
//定义继承于Car的Truck类
class Truck extends Car
{
public function speedUp(){
$this->speed=Car::speedUp();
return $this->speed+=40;
}
}
$car = new Truck();
$car->speedUp();
echo $car->speed;
可可可可啊
2014-10-03
0 回答
举报
0/150
提交
取消