在使用類的魔術方法"__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,即不再出現該提示。