public static function __get($value)
does not work, and even if it did, it so happens that I already need the magic __get getter for instance properties in the same class.
This probably is a yes or no question, so, it is possible?
Static properties are accessed using the Scope Resolution Operator ( :: ) and cannot be accessed through the object operator ( -> ). It's possible to reference the class using a variable. The variable's value cannot be a keyword (e.g. self , parent and static ). print $foo::$my_static .
PHP calls the __get() method automatically when you access a non-existing or inaccessible property. PHP calls the __set() method automatically when you assign a value to a non-existing or inaccessible property.
Magic methods are special methods which override PHP's default's action when certain actions are performed on an object. All methods names starting with __ are reserved by PHP. Therefore, it is not recommended to use such method names unless overriding PHP's behavior.
The __toString() function returns the string content of an element. This function returns the string content that is directly in the element - not the string content that is inside this element's children!
No, it is not possible.
Quoting the manual page of __get :
Member overloading only works in object context. These magic methods will not be triggered in static context. Therefore these methods can not be declared static.
In PHP 5.3, __callStatic
has been added ; but there is no __getStatic
nor __setStatic
yet ; even if the idea of having/coding them often comes back on the php internals@ mailling-list.
There is even a Request for Comments: Static classes for PHP
But, still, not implemented (yet ? )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With