求大神给我讲一下具体区别
<?
class employee
{
private $sal = 3000;
//protected $sal = 3000;
public function getSal() {
return $this->sal;
}
}
class Manager extends employee
{
protected $sal = 5000;
public function getParentSal() {
return parent::getSal();
}
}
$manager = new Manager();
echo $manager->getSal();
echo "<br />";
echo $manager->getParentSal(); 第五行的两种表达输出时两种不同结果,区别在哪?
<?
class employee
{
private $sal = 3000;
//protected $sal = 3000;
public function getSal() {
return $this->sal;
}
}
class Manager extends employee
{
protected $sal = 5000;
public function getParentSal() {
return parent::getSal();
}
}
$manager = new Manager();
echo $manager->getSal();
echo "<br />";
echo $manager->getParentSal(); 第五行的两种表达输出时两种不同结果,区别在哪?
父类中用protected的时候,被子类覆盖了啊!