late static binding in PHP

…衆ロ難τιáo~ 提交于 2019-12-03 16:34:12

The use of late static binding only changes the method that gets chosen for the call. Once the method is chosen, visibility rules are applied to determine whether or not it may be called.

For B, A::test finds and calls A::foo. The comment in B isn't correct--foo isn't copied to B. Since it's private, it is only callable from other methods in A such as A::test.

C fails because the late static binding mechanism locates the new private method C::foo, but A's methods don't have access to it.

I recommended that you reserve late static binding for static fields and methods to avoid confusion.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!