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

后端 未结 7 1123
逝去的感伤
逝去的感伤 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:11

    In many cases, an interface definition helps other modules guarantee the behavior and the API of a class. In those cases, private methods are not something the other modules can access or understand. That's why you can never put private methods on an interface.

提交回复
热议问题