Created
February 3, 2016 10:54
-
-
Save bpteam/955bd4433bbe018779bd to your computer and use it in GitHub Desktop.
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() будет скопирован в В, следовательно его область действия по прежнему А, | |
и вызов будет успешен*/ | |
} | |
class C extends A { | |
private function foo() { | |
/* исходный метод заменен; область действия нового метода С */ | |
} | |
} | |
$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