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

后端 未结 7 1137
逝去的感伤
逝去的感伤 2021-02-01 12:00

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

Right now I have:

interface iService
{
    private method1();
}
         


        
7条回答
  •  春和景丽
    2021-02-01 12:20

    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.

提交回复
热议问题