Home >Backend Development >PHP Tutorial >Introduction to PHP 8 Object Oriented 2 Abstract Class
(Click to go to)JAVA's abstract class
<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('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
The above introduces PHP Introduction 8 Object-Oriented 2 Abstract Classes, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.