Created
September 30, 2014 22:51
-
-
Save tarunama/3e23826cd4b678de559c to your computer and use it in GitHub Desktop.
[PHP]抽象クラス ref: http://qiita.com/tarunama/items/165b0b46c83d92fa0aad
This file contains 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 | |
abstract class Working | |
{ | |
abstract protected function where(); | |
abstract protected function why(); | |
abstract protected function how(); | |
public function work() | |
{ | |
echo $this->where($where); | |
echo $this->why($reason); | |
echo $this->how($how); | |
} | |
} | |
class Person extends Working | |
{ | |
protected function where() | |
{ | |
return '横浜で'; | |
} | |
protected function why() | |
{ | |
return 'お金欲しいから'; | |
} | |
protected function how() | |
{ | |
return '営業する'; | |
} | |
} | |
$bob = new Person(); | |
$bob->work(); // 横浜でお金欲しいから営業する |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment