Home >Backend Development >PHP Tutorial > 关于PHP面向对象的一个有关问题

关于PHP面向对象的一个有关问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 13:00:33822browse

关于PHP面向对象的一个问题
请教大家,先不管下面的代码设计是否合理,只看代码执行,会是什么结果,为什么是这样的结果。

<br />
<?php<br />
class aaa<br />
{<br />
    function show()<br />
    {<br />
        echo $this->str;<br />
    }    <br />
}<br />
<br />
class sss extends aaa<br />
{<br />
    protected $str='12345';   <br />
}<br />
<br />
$s=new sss();<br />
$s->show();<br />
?><br />

------解决方案--------------------
说说你哪些地方不理解
------解决方案--------------------
子类继承父类公开方法,同名则覆盖

这样明白了吧?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn