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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -