类和接口是不同的。类里是有程序实现的;而接口无程序实现,只可以预定义方法 extends 继承类
class A extends B implements C,D,E
extends 继承类implements 实现接口
/** 类和接口是不同的。类里是有程序实现的;而接口无程序实现,只可以预定义方法 extends 继承类 class A extends B implements C,D,E extends 继承类implements 实现接口 abstract FilterIterator extends IteratorIterator implements OuterIterator { // 方法 public abstract bool accept ( void )//必须实现 public __construct ( Iterator $iterator ) public mixed current ( void ) public Iterator getInnerIterator ( void ) public mixed key ( void ) public void next ( void ) public void rewind ( void ) public bool valid ( void ) } **/ class A{ public $name = ‘A‘; } class B extends A{ } class C extends B implements D,E{ public function aa(){}//程序实现 public function bb(){} public function dd(){} } interface D{ //public $bb;报错 //public function aa(){}//报错 //private function bb();报错 //protected function bb();报错 public function aa(); public function bb(); } interface E{ public function bb(); public function dd(); } $c = new C; echo $c->name; exit;
时间: 2024-10-10 23:57:42