As long as there is one method in a class that is abstract, the class is defined as an abstract class, and conversely, abstract classes are not necessarily all abstract methods.
Subclasses that can be instantiated must implement all of the abstract methods in the parent class of the abstract class, otherwise the error, in other words, is:
Subclasses must implement all the abstract methods in the parent class, otherwise there are abstract methods in the subclass, then the subclasses are abstract classes, or they cannot be instantiated. To instantiate an abstract class, you must use it to implement a subclass of all abstract methods, which can also write methods that the parent class does not have.
Interface feeling is the template of the class, the implementation of an interface will have to implement all the methods in the interface, less one can not.
To instantiate an interface or abstract class, all of the abstract methods within the parent class are implemented.
================================ The following is reproduced, said too good =================================
What is the difference between an interface and an abstract class
What is the basis of your choice to use interfaces and abstract classes?
The concepts of interfaces and abstract classes are different. An interface is an abstraction of an action, and an abstract class is an abstraction of the root.
The abstract class represents what this object is. The interface represents what this object can do. For example, men, women, these two classes (if it's a class ...) ), their abstract class is human. Description, they are all human.
People can eat, dogs can eat, you can define "eat" as an interface, and then let these classes to implement it.
Therefore, in high-level languages, a class can inherit only one class (abstract class) (just as people cannot be both biological and non-living), but can implement multiple interfaces (eating interfaces, walking interfaces).
1th. An interface is a variant of an abstract class, and all methods in an interface are abstract. Abstract classes are classes that declare the existence of a method without implementing it.
2nd. Interfaces can inherit multiple, abstract class not
3rd. An interface definition method cannot be implemented, whereas an abstract class can implement a partial method.
When you focus on the nature of a thing, use an abstract class, and when you focus on an operation, use an interface.
Abstract classes are much more powerful than interfaces, but the cost of defining abstract classes is high. Because of the high-level language (which is actually designed), each class can inherit only one class. In this class, you must inherit or write all of its subclasses.
All commonalities. Although the interface is much weaker in functionality, it is only a description of an action. And you can implement multiple interfaces in one class at the same time. In the design phase will reduce the difficulty.
=========================================================================================
This article is from the "Kuibu, the end of the Great God" blog, please be sure to keep this source http://8210504.blog.51cto.com/8200504/1585721
PHP abstract class, interface differences