什么时候该用$this
<?php
class Human{
public $name;
public $height;
public $age;
public function eat($food){
echo $this->name."'s eating ".$food."\n";
}
}
class NbaPlayer extends Human {
function __construct($name){
$this->name = $name;
}
}
$jordan = new NbaPlayer("Jordan");
echo $this->name."\n";//这里用this为什么不行
$this->eat("apple");//这里用this为什么不行