updating object state from another class
<p>Hello all i'm a noob here and to oophp.</p>

<p>I'm looking to update an exiting objects state from another class.</p>

<p>So in the main file i have...</p>

<pre><code>$obj1 = new class1();
$obj2 = new class2();
</code></pre>

<p>and in class1 i have i setter method that changes the objects state.</p>

<p>soooo what i'm looking at doing, from within an existing method of class2 is something like this...</p>

<pre><code>$obj1-&gt;updateName('Bob');
</code></pre>

<p>Static Methods are no good as i have to relate to the same objects state later. </p>

<p>here's a one page example....</p>

<pre><code>class class1(){

    private $name = '';

    public function updateName($nameIn){
        $this-&gt;name = $nameIn;
    }

}

class class2(){

    public function someFuntion(){

        //OTHER CODE//

        $obj1-&gt;updateName('Bob');
    }
}


$obj1 = new class1();
$obj2 = new class2();

$obj2-&gt;someFuntion();
</code></pre>

<p>Hope this makes some sense.</p>
