Re: unable to create class from constant

From: Date: Mon, 19 Sep 2005 15:55:11 +0000
Subject: Re: unable to create class from constant
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-19077@lists.php.net to get a copy of this message
> But I was wondering if anyone could enlighten me as to why php would > be upset interpreting the constant as the class name. Thanks. class Foo { function get_name() { return 'Foo'; } } class Bar { function get_name() { return 'Bar'; } } define('Foo', 'Bar'); $C = new Foo(); echo $C->get_name(); // output: Foo // you might have been expecting: Bar This "issue" also affects static method calls: Foo::get_name(); // returns: Foo // even though Foo (the constant) resolves to: Bar HTH. S

« previous php.internals (#19077) next »