title: PHP variable var_dump = NULL?
body: <p>I have a PHP script that calls the function fileRead2 function from the file fileRead2.php.</p>
  
  <p>The function below reads username.txt (Which display's the username).</p>
  
  <p><strong>vim fileRead2.php</strong></p>
  
  <pre><code>&lt;?php
  function fileRead2() {
      global $fh, $line;    
      $fh = fopen('username.txt','r');
      while ($line = fgets($fh)) {
          // &lt;... Do your work with the line ...&gt;
          echo($line);
      }
      fclose($fh);
  }
  ?&gt;
  </code></pre>
  
  <p>If I run  the linux command cat on the linux filesystem it show's 'tjones' (the username.)</p>
  
  <p>I run the below in a script.</p>
  
  <pre><code>&lt;?php
  // Read the Username
  require_once('fileread2.php');
  
  $userName = fileRead2();
  echo $userName;
  var_dump($userName);
  &gt;?
  </code></pre>
  
  <p>It echo's <code>$userName</code> that display's 'tjones' however var_dump show's its output as NULL. </p>
  
  <p>Is there any reason why var_dump shows the <code>$userName</code> variable as NULL, when it should be string 'tjones'?</p>
  
  <p>The reason I ask is because I need the variable <code>$userName;</code> for other parts of code and because it's NULL nothing else is working, and I have no idea why?</p>