在使用类的魔术方法"__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,即不再出现该提示。