title: PHP Accessing function in global scope from a class method
body: <p>I have the following simple code:</p>
  
  <pre><code>$a = 'hello';
  
  function myfunc() {
      echo 'in myfunc';
  }
  
  class myclass {
      function __construct() {
          myfunc();
          echo $a;
      }
  }
  
  $m1 = new myclass();
  </code></pre>
  
  <p>The echo $a within the method gives an error as you would expect since $a is in the global scope and cannot be accessed from within the class without first declaring it as global.  That is documented in the PHP manual.</p>
  
  <p>The call to myfunc() does work and I don't understand why.  It is also declared in the global scope but the method can access it without first declaring it as global.  I can't seem to find anything in the PHP manual that explains why this works.</p>
  
  <p>Maybe I've been doing PHP for too long and this is something so simple I've forgotten how it works.  Any insight or a link to where in the PHP manual it says you can access a global function from within a class method would be appreciated.</p>
  
  <p>thanks in advance. </p>