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...
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