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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to