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

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

    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 ;-)

提交回复
热议问题