Difference between Abstract Class and Interface In PHP

 

Abstract Classes

  • An abstract class can provide some functionality and leave the rest for derived class.
  • The derived class may or may not override the concrete functions defined in base class.
  • The child class extended from an abstract class should logically be related.

Interface

  • An interface cannot contain any functionality. It only contains definitions of the methods.
  • We can have a class extend from more than one Interface.
  • The derived class must provide code for all the methods defined in the interface.
  • Completely different and non-related classes can be logically grouped together using an interface.

Leave a Reply