Not parent class, mind you. What I'm wondering if there's any way to set up a class whose objects will only ever be used by objects of another class (its 'parents'), and give the child objects the ability to call methods of the parent objects. Like this:
<?
class a {
var $b;
var $somevar = 'nothing';
function a() {
$this->b = new b;
}
function a_function() {
$somevar = 'something';
}
}
class b {
function b_function() {
// this, of course, is the tricky part
$parent_object->a_function();
// is there any way to do this?
}
}
$foo = new a;
$bar = new b;
$bar->b_function();
print $foo->somevar;
?>
Ideally, {$foo->somevar} is now set to 'something'. But I haven't found any way to reference $parent_object->a_function().
The first thing I tried was to set up the constructor for class b to accept a reference to it's parent object. That didn't work, as PHP apparently starts making copies of the referenced object, which then each contain a new $b, and I ended up in a recursive. No good.
Does anyone know if this is even possible?