<?php
interface myusbkou
{
function type();//类型
function action();//执行的操作
}
class zip implements myusbkou
{ //继承接口
function type()
{
echo "USB的2.0接口";
}
function action()
{
echo "--->需要USB 2.0驱动";
}
}
class mp3 implements myusbkou
{
function type()
{
echo "MP3的1.0接口";
}
function action()
{
echo "--->需要MP3 1.0驱动<br/>";
}
}
class mypc
{
function usbthing($thing)
{
$thing->type();
$thing->action();
}
}
$p=new mypc();
$mp3=new mp3();
$zip=new zip();
$p->usbthing($mp3);
$p->usbthing($zip);
?>
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)