課程
/后端開發
/PHP
/PHP進階篇
為什么過不了…
2014-06-20
源自:PHP進階篇 2-4
正在回答
可以
<?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 $car -> speedUp();
echo $car->speed;
$this -> speed += 10; 分號寫錯了!
舉報
輕松學習PHP中級課程,進行全面了解,用PHP快速開發網站程序
1 回答
2 回答
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2014-08-06
可以
<?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;
2014-06-26
$this -> speed += 10; 分號寫錯了!