-
- class Bar
- {
- public function test() {
- $this->testPrivate();
- $this->testPublic();
- }
- public function testPublic() {
- echo "Bar::testPublicn";
- }
- private function testPrivate() {
- echo "Bar::testPrivate";
- }
- }
- 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
Copy code
Why does Bar::testPrivate appear in the first line?
some documents:
Contents of 7 in this folder
On the PHP official website, the contributors about this code responded:
http://www.php.net/manual/zh/language.oop5.visibility.php#87413
|