title: Global variable inside a constructor with PHP
body: <p>This should be obvious, but I'm getting a bit confused about PHP variable scope.</p>
  
  <p>I have a variable inside a Constructor, which I want to use later in a function in the same class. My current method is this:</p>
  
  <pre><code>&lt;?php
  
  class Log(){
  
     function Log(){
        $_ENV['access'] = true;
     }
  
     function test(){
        $access = $ENV['access'];
     }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>Is there a better way to do this than abusing environment variables? Thanks.</p>