title: Read user home directory from PHP
body: <p>I cannot find a way to get the user's home directory (e.g. <em>/home/jack</em>; whatever ~ in bash points to) in PHP using CGI (suPHP). The $_ENV array is empty, and getenv('HOME') returns nothing.</p>
  
  <p>The reason I want to do this is that in absense of configuration saying otherwise, I want to find variable files used by my application in <em>/home/user/.myappnamehere</em>, as most Linux applications do.</p>
  
  <hr>
  
  <p>I've built something, but it's not the best; While it works, it assumes a lot about the system (e.g. the presence of /etc/passwd)</p>
  
  <pre><code> $usr = get_current_user();
      $passwd = file('/etc/passwd');
      $var = false;
      foreach ($passwd as $line) {
          if (strstr($line, $usr) !== false) {
              $parts = explode(':', $line);
              $var = realpath($parts[5].'/.report');
              break;
          }
      }</code></pre>