I'm trying to share methods between objects that belong to a parent object.
I have a main object, which has child objects that handle different tasks. These are created using the main objects constructor:
class engine {
public function __construct() {
$this->db = new db();
$this->url = new url();
$this->template = new template();
}
}
Here's an example of how I would use my main object:
$engine = new engine();
$engine->db->connect();
$engine->url->parse();
$engine->template->render();
How could the child objects access the methods of the other children (e.g. how could template->render()
call url->parse()
) ?