Page 1 of 1

a class inside a class

Posted: Sun Jun 06, 2004 6:21 pm
by johnrau_
hi, i've been trying to use the functionality of one class inside another:

should the following code work in theory?

Code: Select all

class out {
    var $output = "yay";
    function put() {
        echo $this->$output;
    }
}

class test {
    function testme() {
        global $out;
        $out->put();
    }
}

$out = new out;
$test = new test;

$test->testme();
the above should output yay, right?

thanks
j

Posted: Sun Jun 06, 2004 7:22 pm
by launchcode
It will if you fix you echo statement :)

Code: Select all

echo $this->output;
Note the lack of $