Re: Instantiating class, classname in constant
| From: | Catalin Trifu | Date: | Mon, 30 Aug 2004 16:10:38 +0000 |
| Subject: | Re: Instantiating class, classname in constant | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195165@lists.php.net to get a copy of this message | ||
Hi,
> <?php
> class Foo {
> const Bar = 'Foo_Bar';
> const Chocolate = 'Foo_Chocolate';
> const Target = 'Foo Target';
> }
>
> $bar = new Foo::Bar();
> ?>
Foo::Bar() is taken by php as a function call and then it tries to
instantate whatever that function returns.
This is quite logical behaviour since function calls always end up with
().
When you call
$bar = new Foo::Bar;
then the Foo::Bar is definetely refering to constant Bar in class Foo
Cheers,
Catalin