(點選前往)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></code>').addClass('pred -numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了 PHP入門8 物件導向2 抽象類,包含了面向的內容,希望對PHP教學有興趣的朋友有幫助。