Hi List,

 

I need to be able to access a other variables in a parent class from an
object inside the parent class. Here's what I've cooked up, but it throws a
*RECURSION* warning:

 

<?php

Class A {

    var $msg = 'Why hello there my old friend';

    var $b;

 

    function  __construct() {

        $this->b = new B($this);

    }

}

 

Class B {

    var $a;

    function __construct($a) {

        $this->a = $a;

    }

}

 

$a = new A();

$b = $a->b;

echo $b->a->msg;

// Output: Why hello there my old friend

 

print_r($a);

/* Output:

(

    [msg] => Why hello there my old friend

    [b] => B Object

        (

            [a] => A Object

 *RECURSION*

        )

 

)

*/

?>

 

Is the *RECURSION* warning bad coding on my part? What's a best practice
here?

 

Thanks!

 

Kirk Ouimet

 <mailto:[email protected]> [email protected]

Cell: (801) 310-1421

 

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to