Created
December 3, 2010 18:45
-
-
Save jmikola/727351 to your computer and use it in GitHub Desktop.
Testing static::nonStaticMethod()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class A { | |
| private function foo() { | |
| echo "success!\n"; | |
| } | |
| public function test() { | |
| $this->foo(); | |
| static::foo(); | |
| } | |
| } | |
| class B extends A { | |
| /* foo() will be copied to B, hence its scope will still be A and | |
| * the call be successful */ | |
| } | |
| class C extends A { | |
| public function foo() { | |
| echo "great success!\n"; | |
| /* original method is replaced; the scope of the new one is C */ | |
| } | |
| } | |
| $b = new B(); | |
| $b->test(); | |
| $c = new C(); | |
| $c->test(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment