[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,即不再出現該提示。


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