title: Global variable in PHP is not working
body: <p>I need to access <code>$layers</code> from inside the function <code>isOk($layer)</code>, but everything i tried the outside function variable <code>$layers</code> is ok, but inside the function, even with global is return null.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>$layers = array();
  foreach($pcb['PcbFile'] as $file){
      if(!empty($file['layer'])){
          $layers[$file['layer']] = 'ok';
      }
  }
  // Prints OK!
  var_dump($layers);
  
  function isOk($layer){
      global $layers;
  // Not OK! prints NULL
      var_dump($layers);
      if(array_key_exists($layer, $layers))
          return ' ok';
      return '';
  }
  // NOT OK
  echo isOk('MD');
  </code></pre>
  
  <p>I always use Object orientation, but this was something so simple that i made with a simple function... Why <code>$layers</code> is not being 'received' correcly inside the function?</p>