Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make __set also work for static operation in PHP?

When I call self::$parameter = 1; the __set is not called.

Is there a way to workaround?

like image 399
user198729 Avatar asked Jan 19 '26 10:01

user198729


1 Answers

From the 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.

So, I'm afraid not.

like image 177
deceze Avatar answered Jan 22 '26 01:01

deceze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!