I'm using two objects which are object of 2 different classes: $obj1 (of class1) and $obj2 (of class2)
class class1 {
var $var1;
}
class class2 {
function shout() {
echo $obj1->var1;
}
}
$obj1 = new class1;
$obj1->var1 = "hello world";
the problem is that I need to access the variable of obj1 from almost all functions within class2 (there are more functions than in my example above).
to make this work I must set $obj1 global:
function shout() {
global $obj1;
echo $obj1->var1;
}
Is it possible to set $obj1 global for all functions within class2 or do I have to set it global within each function of class2 again and again? any other hints?
Thanks