<?php
class Human{
public $name;
public $height;
public $weight;
private $age=40;//只能在类的内部被访问
public function eat($foot){
echo $this->name."'s eating ".$foot."<br>";
}
}
class NbaPlay extends Human{
public $team = "Bull";
public $playerNumber='23';
function __construct($name,$height,$weight,$team,$playerNumber){
echo "in nabplay"."<br>";
$this->name = $name;//$this是php里的伪变量表示对象自身。可以通过$this->的方式访问对象的属性和方法。
$this->height = $height;
$this->weight = $weight;
$this->team = $team;
$this->playerNumber = $playerNumber;
}
function __destruct(){
echo "lllll".$this->team."<br>";
}
public function run(){
echo "Running\n";
}
public function jump(){
echo "Jumping\n";
}
public function dribble(){
echo "Dribbleing\n";
}
public function shoot(){
echo "Shooting\n";
}
public function dunk(){
echo "Dunking\n";
}
public function pass(){
echo "Passing\n";
}
public function getAge(){
echo $this->name."年龄是".$this->age."<br>";
}
}
$jordan = new NbaPlay('jordan','180cm','160kg','lcl','24');
$jordan->getAge();
echo "<br>";
坚强
qq_大寒_2