Assigning functions

[email protected] (Philip Thompson)
Newsgroups php.general
Message-ID <[email protected]>
Hi all. I have several classes. Within each class, a new class is  
called. Is there a way to assign a function in a *deeper* class to be  
called in the first class? Example to follow......

<?php
class A {
     function __construct () {
         $this->b = new B ();
         // I want to do the following. This does not work, of course.
         $this->doSomething = $this->b->c->doSomething;
     }
}

class B {
     function __construct () {
         $this->c = new C ();
     }
}

class C {
     function __construct () { }
     function doSomething () { echo "¡Hi!"; }
}

$a = new A ();
// Instead of doing this,
$a->b->c->doSomething();

// I want to do this.
$a->doSomething(); // ¡Hi!
?>

Basically, it's just to shorten the line to access a particular  
function. But, is it possible?!

Thanks,
~Philip
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.