Created
July 18, 2013 15:13
-
-
Save hirak/6030128 to your computer and use it in GitHub Desktop.
privateメソッドとfinal ref: http://qiita.com/Hiraku/items/9ef3a63745fe5f7cead9
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 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(); |
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 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(); |
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 { | |
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