View Single Post
Old 01-26-2009, 09:26 PM   #3 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

I would pass it as a reference.

PHP Code:
class extends c
{
private 
$classB;

public function 
setClassB($class)
{

if(
is_object($class)
{
$this->classB $class;
}

}


PHP Code:
$b = new classB();
$d = new classD();
$d->setClassB($b); 
Or you could design it to be added in the __construct function so you would simply use this:
PHP Code:
$b = new classB();
$d = new classD($b); 
And to use the class b functions inside your class d, you just do like this:
PHP Code:
$result $this->classB->function($args); 
__________________
Tanax is offline  
Reply With Quote