In that class B I 'reaload' class A.
Now the problem is that now all the class variables from class A are now back to default. How can I see if ANYWHERE there is an instance of class A and then return a reference to that instance so when I use class A inside class B all the variables are still there.
small example:
Code: Select all
public function ViewResults()
{
$SR = $this->LoadClass('Search', 'Controller');
//i don't want to have to run $SR->Search() again as it has already been done
//but if i don't then $SR->Results will just be a empty string
//how can I have had $SR return the previous instance of that class
$SR->Search();
$Show = '';
foreach ($SR->Results as $Result)
{
$Show .= $Result['Name'].'<br>';
}
return $Show;
}Code: Select all
public function LoadClass($class, $level)
{
global $Config;
require_once $Config[$class]['Path'].$class.'.'.$level.'.class.php';
$ClassName = $class.$level;
$tmp = new $ClassName;
return $tmp;
}