Re: Instantiating class, classname in constant
| From: | Frédéric Hardy | Date: | Mon, 30 Aug 2004 14:07:45 +0000 |
| Subject: | Re: Instantiating class, classname in constant | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195162@lists.php.net to get a copy of this message | ||
I don't know.
Ask them !
Fred.
Wouter van Vliet wrote:
Quoting Frédéric Hardy <f.hardy@hexanet.fr>:-- =================================================================== Frederic HARDY Email: fch@hexanet.fr HEXANET SARL URL: http://www.hexanet.fr/ ZAC Les Charmilles Tel: +33 (0)3 26 79 30 05 3, allée Thierry Sabine Direct: +33 (0)3 26 61 77 84 BP 202 - 51686 REIMS CEDEX 2 FRANCE ===================================================================Thought so, .. but what I am interested in is why the php team (or zend) decided to not make that possible. It would result in so much better support for "packages" of modules. Especially when mixed up with some cool __autoload() tricks.Hi Fella's, Some of you might or might not remember me. I've been here before and I amhereagain. Hoping to stick around, ask, wonder and help a lot. So much for a starter. Now, aren't all of you as excited about php5 as I am? What a great changeto theobject model. Especially, .. well, basically all modifications are as goodasall of the others. There's only one thing I can't seem to get working - not after googling, trying, searching, reading. Not even after just trying everything I thought to be reasonable. It's the following: <?php class Foo {it'sconst Bar = 'Foo_Bar';const Chocolate = 'Foo_Chocolate';const Target = 'Foo Target';} $bar = new Foo::Bar(); ?> even though <?php $bar = Foo::Bar; $bar = new $bar(); ?> does instantiate an object of class Foo_Bar; After all this time I've given up on it, please ow please just tell me whynot working. Same thing, btw, doesn't work for $obj = new __CLASS__(); oranyobject instantiation where the classname should come from something elsethen aregular, scalar variable. Any discussion on the item would be great, WouterHello - It is not possible to do that. PHP new keyword does not support constant in argument, only string or variable :-(. Fred.