faqts : Computers : Programming : Languages : PHP : kms : Classes

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

16 of 19 people (84%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do I reference a variable that is defined inside a class?

Jun 10th, 1999 07:00
Nathan Wallace, Rasmus Lerdorf


You need to do $object->var.  For example:

class Foo {
    var $i;

    function Foo() {
        $this->i = new Bar;
    }
}

$f = new Foo;

echo $f->i;