title: Best practice in PHP to keep instances global or within function scope
body: <p>I have a class which is used by amfphp and I am using some other classes in it to do multiple tasks. I am curious that what will be the best practice to keep instances of those classes either global or within function scope.</p>
  
  <p>for e.g.</p>
  
  <p>For global variable $config. I use it like this in functions:</p>
  
  <pre><code>global $config;
  </code></pre>
  
  <p>For scope variable I do this.</p>
  
  <pre><code>$config = new Config();
  </code></pre>
  
  <p>now when my program runs it process the specific task and shutdown everything(I assume) and for another different task call same again.</p>
  
  <p>Now which one is better and performance effective ?</p>