$this as function parameter
| From: | Moritz Petersen | Date: | Sun, 07 Jan 2001 12:15:51 +0000 |
| Subject: | $this as function parameter | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-33085@lists.php.net to get a copy of this message | ||
Hi Guys,
I'm trying the following:
<code>
class EnvironmentContainer
{
var $environment;
function set_environment($environment)
{
$this->environment = $environment;
}
}
class GlobalEnvironment
{
var var1 = "hello world!";
var content;
function init()
{
$this->content = new Content();
$this->content->set_environment($this);
}
function echo_all()
{
$this->content->echo_content();
}
}
class Content extends EnvironmentContainer
{
function echo_content()
{
echo $this->environment->var1;
}
}
$global_env = new GlobalEnvironment();
$global_env->init();
$global_env->echo_all();
</code>
Which produces: NOTHING! Not even an error-message! Why?
It should produce: "hello world!".
Has anyone an answer?
Thanks,
Mo.