<?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");
?>