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

From: Date: Tue, 29 Jun 2004 11:55:46 +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-189221@lists.php.net to get a copy of this message
Found the solution: function create_car($params){ global $smarty; $car = new Car("Jeep sWrangler","black"); $smarty->register_object($params[id], $car); } "Maris" <proximus@e-teliamtc.lv> wrote in message news:20040629111612.8800.qmail@pb1.pair.com... > 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 > } > > > Thanks, > Maris

« previous php.general (#189221) next »