What is the difference between abstract methods and interface methods in terms of implementation requirements?
Last updated
Interface methods are implicitly
publicwith no body, and a class can implement many interfaces, so they form a pure capability contract.Abstract methods live in an
abstractclass alongside concrete methods, properties and constructors, but a class can onlyextendsone parent.In both cases the concrete child must implement every declared method or it fails (unless the child is itself abstract). Use an abstract class when you also want to share base behavior.
- https://www.php.net/manual/en/language.oop5.abstract.php
- https://stackoverflow.com/questions/37437633/php-if-all-methods-in-abstract-class-are-abstract-then-what-is-the-difference
- https://www.php.net/manual/en/language.oop5.interfaces.php
- https://www.geeksforgeeks.org/php/php-interface/
- https://stackoverflow.com/questions/57387790/what-is-difference-between-abstract-method-and-interface-method-in-php
- https://www.geeksforgeeks.org/php/traits-vs-interfaces-in-php/
- https://www.interviewbit.com/blog/features-of-oops/