Re: Referencing a "constant" class variable

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

 



On Wed, 6 Oct 2004 13:02:18 -0500, Greg Donald <destiney@xxxxxxxxx> wrote:
> On Wed, 6 Oct 2004 11:08:22 -0500, Chris Boget <chris.boget@xxxxxxxx> wrote:
> > If I have a class that looks like this:
> >
> > class MyClass {
> >   var $MyClassVar = "Bob";
> > }
> >
> > is there a way to reference that variable w/o instantiating
> > MyClass?  I've tried:
> 
> MyClass::MyClassVar

That's wrong, I was thinking of functions.  Sorry.

Seems you have to instantiate the class.

class MyClass {
    var $MyClassVar = "Bob";
}

$class = new MyClass;
echo $class->MyClassVar;


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

-- 
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