为什么过不了…
2 回答
可以
<?php
class Car {
public $speed = 0;
//增加speedUp方法,使speed累加10
function speedUp() {
$this -> speed = ($this -> speed + 10);
$this -> speed += 10;
echo $this -> speed + 10;
echo '<br/>';
return $this -> speed + 10;
}
}
$car = new Car();
print_r($car->speedUp());
echo '<br/>';
echo $car -> speedUp();
echo '<br/>';
echo $car->speed;
举报
0/150
提交
取消