Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hirak/6030128 to your computer and use it in GitHub Desktop.
Save hirak/6030128 to your computer and use it in GitHub Desktop.
privateメソッドとfinal ref: http://qiita.com/Hiraku/items/9ef3a63745fe5f7cead9
<?php
class A {
private function echoClass() {
echo 'A', PHP_EOL;
}
public function p() {
$this->echoClass();
}
}
class B extends A {
private function echoClass() {
echo 'B', PHP_EOL;
}
public function p() {
$this->echoClass();
}
}
$a = new A;
$a->p();
$b = new B;
$b->p();
<?php
class A {
private function echoClass() {
echo 'A', PHP_EOL;
}
public function p() {
$this->echoClass();
}
}
class B extends A {
private function echoClass() {
echo 'B', PHP_EOL;
}
}
$a = new A;
$a->p();
$b = new B;
$b->p();
<?php
class A {
final private function echoClass() {
echo 'A', PHP_EOL;
}
}
class B {
private function echoClass() {
echo 'B', PHP_EOL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment