title: Unable to access global variable in included file
body: <p>I am having an unexpected issue with scope. The <a href="http://php.net/include" rel="nofollow"><code>include</code> documentation</a> (also applies to <code>require_once</code>) says the required file should have access to all variable at the line it was required. </p>
  
  <p>For some reason I am not able to access a class instantiated with global scope inside a function that was required in. </p>
  
  <p>Would anyone know why? I am obviously missing something.</p>
  
  <p>I got it working through a reference to <code>$GLOBALS[]</code>, but I still want to know why it is not working.</p>
  
  <p><strong>UPDATE:</strong>
  <br>
  The error I am getting is:</p>
  
  <pre><code>Fatal error: Call to a member function isAdmin() on a non-object in &lt;path&gt;.php on &lt;line&gt;
  </code></pre>
  
  <p>Code:<br></p>
  
  <pre><code>$newClass = new myClass();
  
  require_once("path to my file");
  
  ----- inside required file -----
  function someFunction() {
       $newClass-&gt;someMethod(); // gives fatal error. (see above).
  }
  </code></pre>