Difference between Abstract class and Interface in PHP
S.No
|
Abstract Class
|
Interface
|
1
| For abstract class a method must be declared as abstract. Abstract methods doesn’t have any implementation. | For interface all the methods by default are abstract methods only. So one cannot declare variables or concrete methods in interfaces. |
2
| The Abstract methods can declare with Access modifiers like public, internal, protected. When implementing in subclass these methods must be defined with the same (or a less restricted) visibility. | All methods declared in an interface must be public. |
3
| Abstract class can contain variables and concrete methods. | Interfaces cannot contain variables and concrete methods except constants. |
4
| A class can Inherit only one Abstract class and Multiple inheritance is not possible for Abstract class. | A class can implement many interfaces and Multiple interface inheritance is possible. |
