Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BernardoBF4's avatar

Example for a class that implements from an interface and extends from an abstract class at the same time

I am currently watching the series on OOP in PHP and I've heard on some searches on the web about how it's possible for a class to implement from an interface and extend from an abstract class, but I have not found one example for that yet.

My idea is that a class that does that must 1) be able to replace another class that implements the same interface (but can't be replaced by another from the same interface, since it can have implementations that the abstract class is giving to it that the interface isn't); and 2) needs to have same common code with other class that extend from the same abstract class.

So... any examples, folks? And also, because of my point in the parenthesis above (correct it if I am wrong), should you extend (from an abstract class) and implement at the same time, ever?

0 likes
0 replies

Please or to participate in this conversation.