Re: Referencing a "constant" class variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Boget wrote:
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

class MyEnums { var $this = 'This'; var $that = 'That'; var $other = 'Other'; }

 class MyClass {
   var $MyVar = MyEnums::this;
 }

reference like MyClass::MyVar. Don't use PHP5 conventions in PHP4!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux