You are here: Re: [PHP] variable object creating « PHP « IT news, forums, messages
Re: [PHP] variable object creating

Posted by "Richard Lynch" on 10/20/62 11:19

On Tue, June 21, 2005 8:33 pm, Eli said:
> 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? */

Did you try:

$instance = new $classname($param1, $param2, $param3);

Or do you really need the parameters in an array?...

You could maybe use call_user_func_array or whatever it is, and write a
tiny function that calls new on the arguments...

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация