Rumah >pembangunan bahagian belakang >tutorial php >PHP入门8 面向对象2 抽象类
(点击转到)JAVA的抽象类
<code><span><span><?php </span><span>//抽象类关键字 abstract 抽象类不能实例化 必须被继承才能使用</span><span>abstract</span><span><span>class</span><span>_parent</span>{</span><span>//抽象方法关键字 abstract</span><span>public</span><span>abstract</span><span><span>function</span><span>fun1</span><span>()</span>;</span><span>//抽象类中可以用非抽象方法</span><span>public</span><span><span>function</span><span>parentfunc</span><span>()</span> {</span><span>echo</span><span>"Hello<br>"</span>; } } <span><span>class</span><span>Test</span><span>extends</span><span>_parent</span>{</span><span>//必须实现抽象类的所有抽象方法</span><span>public</span><span><span>function</span><span>fun1</span><span>()</span>{</span><span>echo</span><span>"class Test<br>"</span>; } } <span>$A</span> = <span>new</span> Test(); <span>$A</span>->fun1(); <span>$A</span>->parentfunc(); <span>?></span></span></span></code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了 PHP入门8 面向对象2 抽象类,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。