简体   繁体   中英

Zend framework modules and Reflection

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.

$modelClass = "{$moduleName}_Model_{$modelName}";
$obj = new $modelClass();
$obj->$function();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM