title: PHP: static variable outside of class
body: <p>I have seen in 3rd party code a variable declared as static, but outside of any class, simply in a "normal" function.</p>
  
  <pre><code>&lt;?php
  function doStuff(){
      static $something = null;
  }
  ?&gt;
  </code></pre>
  
  <p>I have never seen <code>static</code> used this way, and I cannot find anything it in the PHP documentation.</p>
  
  <p>Is this legal PHP code? Is this effectively the same as a global variable? If not, what is the purpose?</p>