Page 1 of 1

A little confused about calling class variables

Posted: Fri Sep 12, 2008 12:00 am
by jonwondering
Okay, if I have:

Code: Select all

class A {
    public $var = 'test';
    function func() {
    }
}
I know I can call A::func(), but can I not call A::var to display the word 'test'? Do I HAVE to create first an object A, and then call it A->var? Or is there a way I just don't know about?
Thanks.

Re: A little confused about calling class variables

Posted: Fri Sep 12, 2008 12:42 am
by Christopher
You should read this section of the PHP manual:

http://www.php.net/manual/en/language.oop5.php