Problem:
This works in PHP 5.3+:
$CLASS_NAME = 'TheName'; $class_instance = new $CLASS_NAME;
This doesn’t
define('CLASS_NAME', 'TheName'); $class_instance = new CLASS_NAME;
Workaround:
Use the way that works. There are other limitations with using a variable to create a class. Another way to create a class from a variable is by using:
$test = call_user_func(array($className, 'getInstance'));