Object type determined at runtime
| From: | James Colannino | Date: | Mon, 06 Jul 2009 08:12:50 +0000 |
| Subject: | Object type determined at runtime | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-294928@lists.php.net to get a copy of this message | ||
Hey everyone. I have a question. Hopefully it's clear, because I'm not
sure quite how to ask it. Basically, I have a variety of different
objects that a variable can be instantiated as in the same block of
code, its type being determined at runtime. I want to be able to do
something like this:
$object = new $objType();
Where $objType is the type of object, which must be determined at
runtime. I'm sure the syntax I have above is incorrect. My question
is, is there any way that I can determine the object's type at runtime
and do the same type of thing?
Thanks!
James