[PLUG] PHP class instances

Daniel B. Herrington dan at fiddlers-green.info
Wed Jun 25 01:32:02 UTC 2003


PHP gurus,

I discovered that I can instantiate classes with a variable name. i.e.:

I create a class called test, then in my script:

$var = test;
$testclass = new $var;

and a new instance of test gets created. I was wondering if this was bad
practice and if I should cease and desist before I make a habit of creating
instances of classes this way?

thanks,
Dan Herrington

-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/





More information about the PLUG mailing list