Re: Function that creates a class instance with a given name

From: Date: Tue, 29 Jun 2004 16:25:42 +0000
Subject: Re: Function that creates a class instance with a given name
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-189230@lists.php.net to get a copy of this message
On Tue, 29 Jun 2004 14:16:16 +0300, Maris <proximus@e-teliamtc.lv> wrote: > > Hi there! > > I am trying to make a PHP function "create_object" that would allow me to > create a class instance with supplied name > > Here's the Smarty code snipset I would like to use my function in: > > {* Let's create a new class object with name "car" *} > {create_object id=$id_car name="car"} > > {* When it is created, we can print out its properties or do whatever we > need to *} > The brand is: {$car->brand} > and car's color is: {$car->color} > > Any ideas how to create PHP function that would allow to create the instance > so I can > operate with it in Smarty as shown above? > > function create_object($id, $name){ > //help needed > } Perhaps: function create_object($class, $name){ $obj = new $class(); $this->assign($name, $obj); } > > Thanks, > Maris > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > !DSPAM:40e14d8b133258412246093! > > -- paperCrane --Justin Patrin--

« previous php.general (#189230) next »