<?php?
class?Human{
public?$name;
public?$height;
public?$weight;
public?function?eat($food){
echo?$this->name."'s?eating".$fond."<br>";
}
}
class?NbaPlayer?extends?Human?{
public?$team;
public?$playerNumber;
function?__construct($name,$height,$weight,$team,$playerNumber){
//$this是php里面的偽變量,表示對象本身。
//可以通過$this->的方式訪問對象的屬性和方法。
$this->name?=?$name;
$this->height?=?$height;
$this->weight?=?$weight;
$this->team?=?$team;
$this->playerNumber?=?$playerNumber;
}?
public?function?run(){
echo?"Running\n";
}
public?function?jump(){
echo?"Jumping\n";
}
}
$player?=?new?NbaPlayer("Jordan","198cm","98kg","BUll","23");
echo?$player->name."<br>";
$player->eat("Apple");
?>

2017-04-18
看清楚你第七行是什么,應(yīng)該是$food,不是$fond
2017-04-28
哈哈,知道了