时间:2021-07-01 10:21:17 帮助过:18人阅读
- abstract class AbstractClass {
- abstract public function test();
- }
- class ImplementedClass extends AbstractClass {
- public function test() {
- echo "ImplementedClass::test() called. ";
- }
- }
- $o = new ImplementedClass;
- $o->test();
PHP 5也支持接口的概念,并为之引入了interface和implements关键字。和Java一样,PHP 5使用接口也实现类似于“多重继承”的效果。PHP5接口语法如下:
- interface displayable {
- function display();
- }
- interface printable {
- function doprint();
- }
- class foo implements displayable,printable {
- function display() {
- // code
- } function doprint() {
- // code
- }
- }
抽象类和PHP5接口的引入使PHP成了一个完全面向对象的语
http://www.bkjia.com/PHPjc/446413.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446413.htmlTechArticle大家对 具体PHP5抽象类的代码如下: abstractclassAbstractClass{ abstractpublicfunctiontest(); } classImplementedClassextendsAbstractClass{ publicfunctiontest(){ echo"Im...