Re: Referencing a "constant" class variable
| From: | Chris Boget | Date: | Wed, 06 Oct 2004 19:34:56 +0000 |
| Subject: | Re: Referencing a "constant" class variable | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-198768@lists.php.net to get a copy of this message | ||
> I believe you can make the property static (at least in PHP5):
> class MyClass
> {
> public static $myClassVar = "Bob";
> }
> echo MyClass::$myClassVar; // Bob
Unfortunately, in PHP4.3.2 that doesn't seem to be working... :(
Does anyone know how I can access a class' variable w/o having
to instantiate an object of the class? This is more to the point of
what I'm trying to do:
Since PHP4 doesn't have enums, I'm doing this:
class MyEnums {
var $this = 'This';
var $that = 'That';
var $other = 'Other';
}
class MyClass {
var $MyVar = MyEnums::$this;
}
But obviously, that's not working. Is there a way I can get
it to work?
thnx,
Chris