RE: create object from variable class.
| From: | Michiel ten Hagen | Date: | Wed, 24 Jul 2002 13:16:30 +0000 |
| Subject: | RE: create object from variable class. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109296@lists.php.net to get a copy of this message | ||
Thx for quick reply,
If I use the following:
$object = new {classname};
I get this a parse error:
Parse error: parse error, expecting
T_STRING' or T_VARIABLE'
or `'$'' in
/home/sites/projects.virtuosys.nl/web/cm/includes/class_crm.inc.php on
line 29
From that I conclude that with this method its not possible to create an
object from a variable class name
Michiel ten Hagen
mtenhagen@virtuosys.nl
06-54673863
-----Oorspronkelijk bericht-----
Van: Mathieu Dumoulin [mailto:mdumoulin@groupimage.com]
Verzonden: Wednesday, July 24, 2002 3:11 PM
Aan: mtenhagen@virtuosys.nl
Onderwerp: Re: create object from variable class.
Simple, you made an error here
You are telling the new operator to look into a variable to get the
classname, to specify the class name as a string do this:
$object = new {$classname};
InsaneCoder
Ps: I never tried this, but I think it is actually going to work, you
got nthing to lose anyway I guess, takes two seconds to try.
"Karel De Groot" <mtenhagen@virtuosys.nl> wrote in message
news:<20020724130121.64455.qmail@pb1.pair.com>...
> Is it possible to create an object from a clas which name is in a
> variable.
>
> Example: (doesn't work)
> $object = new ${$classname};
>
>
>
>