The following works to instantiate a class with a variable name
Code: Select all
$class_name = 'blah';
$newclass = new $class_name();
I want to do something similar, except I want to get an instance of a singleton object. The following code, obviously, throws an error
Code: Select all
$class_name = 'blah';
$newclass = $class_name::instance();
The way I worked around this follows
Code: Select all
$load_driver = create_function('','if(!$retval = '.$driver_name.'::instance()){return false;} return $retval;');
However this is incredibly slow because its a user created function. If you know how to do this without a hack id like to hear it.