Forum Moderators: coopster

Message Too Old, No Replies

Class using other object

         

orion_rus

6:07 pm on Sep 19, 2007 (gmt 0)

10+ Year Member



Hello world i have 2 seperate classes:
$class1=new Class1();
and
class class2 extends otherclass {
function class2()
{
// I need to call method from $class1 ($class1->somemethod())
// - how i can make it here?
// is global $class1 would work? or i need other method?)

}

}

Thanks in advance

eelixduppy

6:17 pm on Sep 19, 2007 (gmt 0)



Not sure if that will work or not. You can, however, pass the class1 variable to class2 through the constructor.


$class2 = new class2($class1);

and then the constructor:


function class2($class) {
etc...
}