Skip to content

Instantly share code, notes, and snippets.

@bpteam
Created February 3, 2016 10:54
Show Gist options
  • Save bpteam/955bd4433bbe018779bd to your computer and use it in GitHub Desktop.
Save bpteam/955bd4433bbe018779bd to your computer and use it in GitHub Desktop.
<?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