php - How to create object from String? -


i tried code below:

$dyn = "new ". $classname . "(" .$param1 . ", ". $param2 . ");"; $obj = eval($dyn); 

it compiles it's null.

how can instance object in php dynamicaly?

$class = 'classname'; $obj = new $class($arg1, $arg2); 

Comments

Popular posts from this blog

List<T>().Add problem C# -

Javascript natural sort array/object and maintain index association -