title: Problem with accessing a global variable in PHP
body: <p>Following is code snippet :</p>
  
  <pre><code>function something() {
  $include_file = 'test.php';
  if ( file_exists($include_file) ) {
      require_once ($include_file);
  //      global $flag;
  //        echo 'in main global scope flag='.$flag;
      test();
     }
  }
  
  something();
  
  exit;
  
   //in test.php
  
  $flag = 4;
  function test() {
     global $flag;
  
     echo '&lt;br/&gt;in test flag="'.$flag.'"';
     if ($flag) {
         echo 'flag works';
       //do something
     }
  }
  </code></pre>
  
  <p>The above code snippet, echoes 'global scope' $flag value properly but doesnt recognises the $flag with value 4, assumes null value for $flag . 
  Please point out what is wrong in accessing that $flag global variable.</p>
  
  <p>Thanks in advance,
  Anitha</p>