为什么$pri用的是父类的属性?
0
为什么不全是调用父类的属性?为什么只有$pri用的是父类的私有属性?
<?php
class father {
public $pub='public';
private $pri='private';
protected $pro='protected';
public function getpri(){
echo $this->pri;
echo $this->pro;
echo $this->pub;
}
}
class son extends father{
public $pub='王二';
private $pri='黄金时代';
protected $pro='沉默的大多数';
public function getpub(){
echo $this->pub.'';
echo $this->pro;
echo $this->pri;
}
}
$son=new son;
$son->getpri();
?>