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#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

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

openssl - Load PKCS#8 binary key into Ruby -