I have a class like:
class MyClass
{
public static $myVariable;
}
... and inside I have this:
public static function set($name, $value)
{
if (true === property_exists('MyClass', $name)) {
self::$name = $value;
}
}
How can I replace:
self::$name
... with the real variable name? I have try:
self::{$name}
... but it works only for methods. I want to have the possibility of change MyClass's variables with a function. For example:
MyClass::set('myVariable', 123);
Some ideas?
self::$namenot work?