3、不要使用extends这个关键字,使用implements实现implements相当于extends
4、一个类可以在继承另一个类的同时,使用implements实现一个接口,也可以实现多个接口(一定要先继承,再实现接口)
/**
* 接口
*/
interface Demo
{
const Name = "妹子";
const Age = 10;
function test();
function test2();
}
echo Demo::Name;//访问常量
/**
* 接口继承接口,用于扩展接口
*/
interface Test extends Demo
{
function test4();
}
/**
* 普通类
*/
class world
{
function test5()
{
}
}
/**
* 继承+接口
*/
class Hello extends World implements Test
{
function test()
{
}
function test2()
{
}
function test3()
{
}
function test4()
{
}
function test5()
{
}
}
以上所述是小编给大家介绍的PHP的抽象类和抽象方法以及接口总结详解整合,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对黑区网络网站的支持!
