How many interfaces can a class implement in PHP?

Arnas Pečelis picture Arnas Pečelis · Feb 11, 2015 · Viewed 26.4k times · Source

I'm looking for an answer to question which is not difficult, but I can't find out how many interfaces can be implemented by one class.

Is this possible?

class Class1 implements Interface1, Interface2, Interface3, Interface4 {
   .....
}

For all the similar examples I found, I've seen that there can be only 2 interfaces implemented by one class. But there isn't any info about what I'm looking for.

Answer

Machavity picture Machavity · Feb 11, 2015

There is no limit on the number of interfaces that you can implement. By definition, you can only extend (inherit) one class.

I would, as a practical matter, limit the number of Interfaces you do implement, lest your class become overly bulky and thus hard to work with.