OOP - transfering object-pointer

From: Date: Tue, 19 Nov 2002 09:50:41 +0000
Subject: OOP - transfering object-pointer
Groups: php.general 
Request: Send a blank email to php-general+get-125046@lists.php.net to get a copy of this message
Currently, I have the following code: <?php class overall { var $loaded; function load($class){ //eval("global \$$class;"); // This didn't work either $this->loaded[] = $class; eval("\$this->$class = new $class;"); return true; } } class foo { var $bar; // Constructor function bar(){ if(!isset($this->bar)){ $this->bar = 1; }else{ $this->bar++; } echo $this->bar."<br>"; } } // Start actual loading $overall = new overall; $overall->load('foo'); foreach($overall->loaded as $key=>$val){ $key =& $overall->$key; } $overall->foo->bar(); $overall->foo->bar(); $overall->foo->bar(); $overall->foo->bar(); // it doesn't understand this $foo->bar(); // line 42 ?> It all works, except for the $foo->bar(); thing... I am wondering how I can turn $overall->foo->bar() to $foo->bar(); as all the things I've tried, don't work, they don't give any errors, except for Fatal error: Call to a member function on a non-object in d:\apache\htdocs\classes.php on line 42... Could anyone help me with this? thanx - Tularis

« previous php.general (#125046) next »