Is it possible to have an interface that has private / protected methods?

The PHP manual page about interfaces explicitly states:

All methods declared in an interface must be public; this is the nature of an interface.

I guess this explains the error you are getting ;-)


Interfaces are used to describe public methods of a class implementing that interface. You can never have a private method in an interface. Any methods in an interface are assumed to be in use and should not be changed.

Interfaces is the PHP link, but this is standard in OO programming.

Tags:

Php

Oop

Interface