Created
October 25, 2017 05:52
-
-
Save sawadashota/d7d631923db6f11b9d09c4447656e58e to your computer and use it in GitHub Desktop.
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 | |
interface aInterface | |
{ | |
public function a(); | |
} | |
interface bInterface extends aInterface | |
{ | |
public function b(); | |
} | |
class C implements aInterface | |
{ | |
public function a() | |
{ | |
echo "I'm function a!\n"; | |
} | |
} | |
class D implements bInterface | |
{ | |
public function a() | |
{ | |
echo "I'm function a!\n"; | |
} | |
public function b() | |
{ | |
echo "I'm function b!\n"; | |
} | |
} | |
function e(aInterface $a) | |
{ | |
echo $a->a(); | |
echo "aInterface is implemented!\n\n"; | |
} | |
function f(bInterface $b) | |
{ | |
echo $b->a(); | |
echo $b->b(); | |
echo "bInterface is implemented!\n\n"; | |
} | |
$c = new C(); | |
e($c); | |
$d = new D(); | |
e($d); // aInterfaceを継承したbInterfaceを引数にしているため、aInterfaceを実装しているといえる | |
f($d); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment