Hi PHP gurus, please look at the following code
class ClassA {
var $b;
function ClassA() {
$this->b =& new ClassB($this);
}
function heyB() {
$this->b->yes();
}
}
class ClassB {
var $a;
function ClassB(&$a) {
$this->a = $a;
}
function yes() {
echo "Yes, I am a ".get_class($this)."<br>";
echo "You are ".get_class($this->a).", and you think I am ".get_class($this->a->b)."<br>";
}
}
$a =& new ClassA();
$a->heyB();
I assume the output should be:
Yes, I am a classb
You are classa, and you think I am classb
but what I get is:
Yes, I am a classb
You are classa, and you think I am
which means get_class($this->a->b) returns nothing, do I use class references in a wrong way? any tips would be greatly appreciated!
Jack