I have a base class that I need to call functions on a class that is referenced in the child class.
Easy enough,
class base_class {
public function
Provide a way for the parent to access the child's static member:
reference()->doSomething();
}
}
class extended_class extends base_class{
protected static $reference;
public function __construct($ref){
self::$reference = $ref;
}
protected function reference(){
return self::$reference;
}
}
class ref {
public function doSomething(){
echo __METHOD__;
}
}
$ref = new ref();
$ec = new extended_class($ref);
$ec->doSomethingWithReference();
print_r($ec);
?>