views:

31

answers:

1

Hello, i'm a bit confused about modules, namespace and reflection.

$obj = new default_Model_foo();
$obj->bar();

The code above runs properly, but i need to add reflection;

I've got these variables:

$moduleName = "default";
$modelName  = "foo";
$function   = "bar";

I would like to instantiate a class at runtime, how can do it?

Thank you! Mirco.

+2  A: 
$modelClass = "{$moduleName}_Model_{$modelName}";
$obj = new $modelClass();
$obj->$function();
Bill Karwin