为什么$pri用的是父类的属性?

0
PHP C/C++ 14772 次浏览

为什么不全是调用父类的属性?为什么只有$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();
?>
请尽量让自己的答案能够对别人有帮助

6个答案

默认排序 按投票排序
0

thanks and nice to see about live train updates

0

Thanks for sharing this codes.

Check this out postknight pets

0

The article is exceptionally good and straightforward. This is precisely what I require.  text twist
 

0

This article is really fantastic and thanks for sharing the valuable post.

Raft Wars 2

1

得到的

0

test