您需要使用关键字来扩展接口,当您需要在类中实现接口时,则需要使用关键字来实现它。extends
implements
您可以在类中使用多个接口。如果你实现接口,那么你需要定义所有函数的主体,就像这样......implements
interface FirstInterface
{
function firstInterfaceMethod1();
function firstInterfaceMethod2();
}
interface SecondInterface
{
function SecondInterfaceMethod1();
function SecondInterfaceMethod2();
}
interface PerantInterface extends FirstInterface, SecondInterface
{
function perantInterfaceMethod1();
function perantInterfaceMethod2();
}
class Home implements PerantInterface
{
function firstInterfaceMethod1()
{
echo "firstInterfaceMethod1 implement";
}
function firstInterfaceMethod2()
{
echo "firstInterfaceMethod2 implement";
}
function SecondInterfaceMethod1()
{
echo "SecondInterfaceMethod1 implement";
}
function SecondInterfaceMethod2()
{
echo "SecondInterfaceMethod2 implement";
}
function perantInterfaceMethod1()
{
echo "perantInterfaceMethod1 implement";
}
function perantInterfaceMethod2()
{
echo "perantInterfaceMethod2 implement";
}
}
$obj = new Home();
$obj->firstInterfaceMethod1();
等等...调用方法