[error汇总]魔术方法__set

在使用类的魔术方法"__set"时,前面加上private会出现下面的错误:

Warning: The magic method __set() must have public visibility and cannot be static in C:\wamp\www\test.php on line 13

主要原因为function __get()方法设置为了private私有属性。PHP中能识别并正确处理,但是它会警告我们function __get()和function __set()必须具备公有属性。即默认的不加private或者增加public,即不再出现该提示。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章