任务:
定义接口
iTalkable 具有⽅法 talk()
定义接口 iPlayable
具有⽅法 play()
定义抽象类 People,实现上述两个接口
定义类 Teacher 继承⾃People
解决方案
talk();
}
function testplay(iPlayable $play)
{
$play->play();
}
$teacher=new Teacher;
testtalk($teacher);
echo "\n";
testplay($teacher);
echo "\n";
var_dump($teacher instanceof Teacher);
echo "";
var_dump($teacher instanceof People);
echo "";
var_dump($teacher instanceof iTalkable);
echo "";
?>
运行结果
task4.jpg