什么是PHP中的抽象类? [英] What is an abstract class in PHP?
问题描述
什么是PHP中的抽象类?
如何使用?
抽象类是至少包含一个抽象方法的类,该方法中没有任何实际代码,仅包含名称和参数,并且标记为抽象".
这样做的目的是提供一种模板,以从中继承并强制继承类实现抽象方法.
因此,抽象类介于常规类和纯接口之间.接口也是抽象类的特殊情况,其中所有方法都是抽象的.
请参见PHP手册的本部分以获取进一步的参考. /p>
What is an abstract class in PHP?
How can it be used?
An abstract class is a class that contains at least one abstract method, which is a method without any actual code in it, just the name and the parameters, and that has been marked as "abstract".
The purpose of this is to provide a kind of template to inherit from and to force the inheriting class to implement the abstract methods.
An abstract class thus is something between a regular class and a pure interface. Also interfaces are a special case of abstract classes where ALL methods are abstract.
See this section of the PHP manual for further reference.
这篇关于什么是PHP中的抽象类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!