Bonjour,
i want to link two objets between them.
When I do this:
$a=new A();
$b=new B(); *
$a->linkToB=&$b;
$b->linkToA=&$a; ***
$a->val=3:
echo $b->linkToA->val; //print 3
echo $a->linkToB->linkToA->val //print 3
it seems to works, but if i place the crazed code in the constructor of A like this:
function A(){
$b=new B();
$this->linkToB=&$b;
$b->linkToA=&$this;
}
and do:
$a=new A();
$a->val=3;
echo $a->val; //print 3
echo get_class($a->linkToB->linkToA); //print a
echo $a->linkToB->linkToA->val //print nothing ???
What wrong in this code?
Is there an issue to link the two object automatically ?
Arlo