<?php
/**
 *  子类重写父类方法和属性
 **/
class Employer
{
protected $sal=3000;
public function getSal()
{
return $this->sal;
}

} class Manager extends Employer
{
protected $sal=5000;
public function getParentSal()
{
return parent::getSal(); //调用父类方法 返回父类属性,为什么会是5000
}
public function getSal()
{
return $this->sal;
}
}
$manager = new Manager;
echo $manager->getParentSal().PHP_EOL;//5000 这是为什么也是5000呢,但是在5.3以下版本好像是3000,求解释????
echo $manager->getSal();//5000
?>
php子类重写父类属性的问题