OOP 'Same-Class' passing<

liunx

Guest
I have a constructor for one class,that tries to pass itself to another class...

/* class declaration,variable declaraton */
function MooCMS($template)
{
$this->start_time = $this->genmicrotime();
$this->StartBuffer($GLOBALS["MooCMS"]["config"]["Buffering"]);
$this->template = new Template($template);
$this->template->set('moocms',&$this);
}
/* more functions */


The idea is to allow the other class that gets the reference sent to it to access the methods of the class the above constructor constructs.Referencing &$this however,does not work.Any suggestions?You just want the class to sue another classes method?

Just have the class be an extesion class.

Example:

class fruit {
code
}
class apple extends fruit {
code
}

The class apple has access to all the methods in fruit because it is a subclass of fruit.Originally posted by WarGiant
You just want the class to sue another classes method?

Just have the class be an extesion class.

Example:

class fruit {
code
}
class apple extends fruit {
code
}

The class apple has access to all the methods in fruit because it is a subclass of fruit.

thanks for that...but it's not exactly what I need.For example...the method it's tring to pass itself to will atchually define a reference to it as a variable for a template.Basically the template class can handle references to classes....but they have to be preinitialized it appears...not initializing at the time of passing the reference.It would basically set $moocms as a reference to the class...which would be used in a template like:


<?$moocms->method();?><br/><?$moocms->anothermethod();?><br/><?$othervar->othermethod();?>


I'd guess it isn't possible tho ^^;;
 
Back
Top