Check the code given below I could not find how class testPrivate () method was called Was there. According to my perception it should call the method from the Fu class i.e. Foo :: testPrivate.
& lt; Php square bar {public function test () {$ this-> TestPrivate (); $ This- & gt; TestPublic (); } Public event testPublic () {resonant "Bar :: Examination of the People's Democracy \ n"; } Private function testPrivate () {resonant "& lt; br> bar :: testPrivate \ n"; }} Square fu times {public function expands testPublic () {resonant "& lt; br & gt; Foo: testPublic \ n"; } PrivatePrint testPrivate () {echo "& lt; br> Foo: testPrivate \ n"; }} $ MyFoo = new foo (); $ MyFoo- & gt; testing (); // time: testPrivate // Foo: testPublic? & Gt; If you want to overload a child's defined methods Enabled class, that method is not declared as protected - and private . testPrivate methods: secure function testPrivate () {echo "& lt; br> : TestPrivate \ n "; } and:
secure function testPrivate () {echo "& lt; br & gt; Foo: testPrivate \ n"; } You will get the expected output:
Foo :: testPrivate Foo :: testPublic
For information, you should take a look at the section of the manual - the quote of the first sentence:
Publicly declared class members can be used everywhere - declared class protected members only Only hereditary and parental classes can be reached.
Members can be declared as private, only the member class defines.
Comments
Post a Comment