Is it possible to define dynamic vars or anyway to do the following?
Example 1:
class base
{
protected static $$dynamicVar;
protected function myFunction($value)
{
$dynamicVar = $value;
self::$$dynamicVar = new $value();
}
}
The idea behind this code is to instantiate new objects, without the base class knowing what objects will be instantiated.
I know instantiating new objects can be dynamic but I need it dynamic generated on static vars.
Thanks,
This is not possible as far as I know, but you can always do something like this:
The more important question here is “Why do you need this?”