php 5 接口

来源:互联网 发布:淘宝运动服装男女 编辑:程序博客网 时间:2024/06/01 23:30
php 5 接口
接口就是模板,什么也不实现。
interface Thingable {
    public function getPrice();
}
任何实现接口的类都要实现接口中所定义的所有方法,否则该类必须声明为 abstract。
否则将出现下面所示的致命错误:


Fatal error: Class aaa contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (IinterfaceName::methodNameN) in D:\www\test.php on line 11


一个类可以继承多个接口
原创粉丝点击