title: Advantage of passing by reference opposed to using global?
body: <p>im looking at the MVC pattern, and I can see in <a href="http://www.phppatterns.com/docs/design/archive/model_view_controller_pattern#the_view" rel="nofollow noreferrer">one example on phppatterns</a> they're passing the model by reference -  any benefit of doing this over a global var? Am I missing something obvious?</p>
  
  <pre><code>class MyView extends View {
    var $model; 
  
    function __construct(&amp;$model){
      $this-&gt;model =&amp; $model;
    }
  
    function productTable($rownum=1) {
      $rowsperpage='20';
      $this-&gt;model-&gt;listProducts($rownum,$rowsperpage);
      while ( $product=$this-&gt;model-&gt;getProduct() ) {
           // Bind data to HTML
      }
    }
  }
  </code></pre>
  
  <p>Any reason why you would do this as apposed to using a global variable? i.e.</p>
  
  <pre><code>class MyView extends View {
    global $model;
  
    function __construct(){ }
  
    function productTable($rownum=1) {
      $rowsperpage='20';
      $model-&gt;listProducts($rownum,$rowsperpage);
      while ( $product=$this-&gt;model-&gt;getProduct() ) {
           // Bind data to HTML
     }
  }
  </code></pre>