php 5.3 - php5 --- method visibility issue -


please have @ below given code.

<?php class bar  {     public function test() {         $this->testprivate();         $this->testpublic();     }      public function testpublic() {         echo "bar::testpublic\n";     }      private function testprivate() {         echo "bar::testprivate\n";     } }  class foo extends bar  {     public function testpublic() {         echo "foo::testpublic\n";     }      private function testprivate() {         echo "foo::testprivate\n";     } }  $myfoo = new foo(); $myfoo->test(); // bar::testprivate                  // foo::testpublic ?>  

in above example, when called $myfoo->test();it called testprivate of bar class how come called testpublic of foo class.

can 1 me in ?

bar.testprivate , foo.testprivate have protected methods instead of private ones. see here more:

http://php.net/manual/en/language.oop5.visibility.php


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -