Home > Backend Development > PHP Tutorial > .子内内部调父类属性或方法.解决方案

.子内内部调父类属性或方法.解决方案

WBOY
Release: 2016-06-13 12:30:30
Original
902 people have browsed it

...子内内部调父类属性或方法...
class A{
     public $m=20;
     function test(){
             echo 1;
     }

}

class B extends A{

...子内内部调父类属性或方法...

}

B继承A,在B类部可以A::test(),parent::test()或者$this->test()这样三种形式调父类的方法,
不知道子类内部调父类属性的方式有几种,难道只有$this->m一种?

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template