复制代码 代码如下: class Bar { public function test() { $this->testPrivate(); $this->testPublic(); } public function testPublic() { echo "Bar::testPublic
"; } private function testPrivate() { echo "Bar::testPrivate
"; } } class Foo extends Bar { public function testPublic() { echo "Foo::testPublic
"; } private function testPrivate() { echo "Foo::testPrivate
"; } } $myFoo = new foo(); $myFoo->test(); // Bar::testPrivate // Foo::testPublic