当我调用 self::$parameter = 1;
时,__set
没有被调用。
有解决办法吗?
最佳答案
来自manual :
Property overloading only works in object context. These magic methods will not be triggered in static context. Therefore these methods should not be declared static. As of PHP 5.3.0, a warning is issued if one of the magic overloading methods is declared static.
所以,我恐怕不会。
关于php - 如何使 __set 也适用于 PHP 中的静态操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2431056/