PHP - 接口 - 多接口

时间:2021-05-19 14:17:21
    /*
* 使用多接口
*/ //定义接口1
interface IPerosn_one{
public function eat();
} //定义接口2
interface IPerson_two{
public function run();
} //定义接口3
interface IPerson_three{
public function water();
} //定义继承自接口的类
class Menperson implements IPerosn_one,IPerson_two,IPerson_three{
function eat(){
echo '吃饭!';
} function run(){
echo '奔跑!';
} function water(){
echo '喝水!';
}
} //实例化一个继承了多接口的类
$menp = new Menperson();
$menp->eat();
$menp->run();
$menp->water();