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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -