title: Returning objects in php?
body: <p>Will returning an object in php make a new instance of that object? </p>
  
  <p>I have a class that stores objects for me in that class is a method that returns any given object. Example;</p>
  
  <pre><code>class Simple {
  
       private $obj = array();
  
  public function loadObj($name) {
  
      $this-&gt;obj[$name] = new $name();
  }
  
  public function getObj($key) {
  
      if(isset($this-&gt;obj[$key])) {
          return $this-&gt;obj[$key];
      }
  }
  }
  </code></pre>
  
  <p>Then in my code I can do things like this,</p>
  
  <pre><code>$a = new Simple();
  $a-&gt;addObj('cat');
  $cat1 = $a-&gt;getObj('cat');
  $cat2 = $a-&gt;getObj('cat');
  </code></pre>
  
  <p>Does this instantiate a new cat everytime?</p>
  
  <p>Say cat had a variable of color and methods of <code>setColor</code> and <code>getColor</code>, if I changed the color with <code>$cat1</code> and fetched it with <code>$cat2</code> would they be the same?</p>
  
  <p>I would test it but I am not at home.</p>