PHP入门8 面向对象2 抽象类

WBOY
Release: 2016-07-28 08:26:21
Original
911 people have browsed it

1.抽象类必须被继承才能使用,不能直接new


2.抽象类可以有非抽象方法


3.子类必须实现所有抽象方法


4.与JAVA的抽象类神似

(点击转到)JAVA的抽象类

//抽象类关键字 abstract  抽象类不能实例化 必须被继承才能使用abstractclass_parent{//抽象方法关键字 abstractpublicabstractfunctionfun1();//抽象类中可以用非抽象方法publicfunctionparentfunc() {echo"Hello
"
; } } classTestextends_parent{//必须实现抽象类的所有抽象方法publicfunctionfun1(){echo"class Test
"
; } } $A = new Test(); $A->fun1(); $A->parentfunc(); ?>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了 PHP入门8 面向对象2 抽象类,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!