interface Isay {
public function say();
}
class hello implements Isay{
public function say(){
echo "hello";
}
}
class world implements Isay{
public function say(){
echo "world";
}
}
function test_say(Isay $isay){
$isay->say();
}
test_say(new hello()); //output:"hello"
test_say(new world()); //output:"world"
PHP使用接口的好处之一
最新推荐文章于 2021-12-01 18:04:21 发布