Copy code The code is as follows:
class Bar
{
public function test() {
$this- >testPrivate();
$this->testPublic();
}
public function testPublic() {
echo "Bar::testPublicn";
}
private function testPrivate() {
echo "Bar::testPrivaten";
}
}
class Foo extends Bar
{
public function testPublic() {
echo "Foo ::testPublicn";
}
private function testPrivate() {
echo "Foo::testPrivaten";
}
}
$myFoo = new foo();
$myFoo->test(); // Bar::testPrivate
// Foo::testPublic
Why is Bar::testPrivate output in the first line?
Some information:
http://www.jb51.net/article/31709.htm
There is also a reply from the contributor about this code on the PHP official website:
http://www.php.net/manual/zh/language.oop5.visibility.php#87413
http://www.bkjia.com/PHPjc/326157.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326157.htmlTechArticleCopy the code The code is as follows: class Bar { public function test() { $this-testPrivate(); $this- testPublic(); } public function testPublic() { echo "Bar::testPublicn"; } private functi...