take this example:
class Parent
{
public function __construct()
{
$this->config = array('a' => 'b');
$this->child = new Child();
}
public function calling()
{
$this->config['b'] = 'b';
$this->child->answering();
}
}
class Child
{
public function answering()
{
return $this->config['b'];
}
}
p.s. I know returning $this->config['b'] won’t work, but I didn’t know how to return what I wanted so I inserted that as a filler.
how can I instantiate the Child class into the Parent class and somehow access the parent variable config inside of the child class.
Use a function?