class session { var $test="TEST"; var $browser;
function init() { $this->browser = new browser; } }
class browser { function parent_test() { return xxx; } }
I tried $this->parent->test but it doesn't work. Can anybody help me?
There is no implicit reference created in an instance of a class to the instance of it's container for fairly obvious reasons when you think about it. The only way you can do what you want to do it to pass a reference to $this to the constructor of the browser class in the session::init method. Something like this...
class session
{
var $test="TEST";
var $browser; function init()
{
$this->browser = new browser($this);
}
}class browser
{
var $session = null; function browser(&$session)
{
$this->session = &$session;
} function parent_test()
{
return $this->session->test;
}
}-- Stuart
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

