Re: variable object creating

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Try something like:

$classname = "MyClass";
$construct_params = array("param1","param2","param3");

$return =null;
if(class_exists($classname)){
  $param=explode(" ',' ", $construct_param);  
# You must add here some security checks....
  eval("$retrun = new $className($param)");
  var_dump($return);
}

Hope this help!
Olivier

Le Mercredi 22 Juin 2005 05:33, Eli a écrit :
> Hi,
>
> I want to create an object in a form that I get the class name and its
> parameters, and I need to create that object...
> How can this been done?
>
> i.e:
> $classname = "MyClass";
> $construct_params = array("param1","param2","param3");
> /* Now create the object with the given classname and params... how? */
>
> -thanks, Eli

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux