title: Global variable not updating inside static Class method in PHP
body: <p>I have a problem with global variables in PHP. My problem is that a global variable that I change inside a static class method isn't updating outside the method.</p>
  
  <p>I've included the code:</p>
  
  <p>test.php</p>
  
  <pre><code>define( 'APP_ID', 'TESTING' );
  $_APP = array( 'test' =&gt; 'test value' );
  include ('appsettings.class.php');
  AppSettings::initApplication();
  </code></pre>
  
  <p>appsettings.class.php</p>
  
  <pre><code>class AppSettings
  {
    public static function initApplication()
    {
      global $_APP;
      session_start();
  
      // Some code here for your initializtions
      self::initAppEngine();
  echo '&lt;pre&gt;Inside initApplication: '; print_r($_APP);
  echo '&lt;pre&gt;Directly printing the session variable: '; print_r($_SESSION[APP_ID] );
    }
  
    private static function initAppEngine()
    {
      global $_APP;
  
      if( isset($_SESSION[APP_ID]) )
      {
        $_APP = &amp;$_SESSION[APP_ID];
      }
      else
      {
        $_SESSION[APP_ID] = array( 'abcd' =&gt; 'hello', 'APP_ID' =&gt; APP_ID );
        $_APP = &amp;$_SESSION[APP_ID];
  die("Refresh the page");
      }
  
      if ( !isset( $_APP['uid'] ) )
        $_APP['uid'] = 0;
  
  echo '&lt;pre&gt;Inside initAppEngine: '; print_r($_APP);
    }
  }
  </code></pre>
  
  <p>The old value of $_APP is coming instead of the new one inside initApplication. Can anyone point out what I'm doing wrong? </p>
  
  <p>Thanks in advance,</p>