title: __DIR__ and DOCUMENT_ROOT return different values, but both work. Why?
body: <p>I have saved this code as dr.php in the root of a client's host. As could be seen in the output, <code>__DIR__</code> is different from <code>$_SERVER['DOCUMENT_ROOT']</code>; but they both find the <code>dr.php</code>. </p>
  
  <p>What is going on? Is it safe to assume <code>DOCUMENT_ROOT</code> <em>always</em> works?</p>
  
  <p><em>Code of dr.php</em></p>
  
  <pre><code>&lt;pre&gt;
  &lt;?php
  var_dump($_SERVER['DOCUMENT_ROOT']);
  var_dump(file_exists($_SERVER['DOCUMENT_ROOT'] . '/dr.php'));
  var_dump(__DIR__);
  var_dump(file_exists(__DIR__ . '/dr.php'));
  ?&gt;
  &lt;/pre&gt;
  </code></pre>
  
  <p><em>The output</em></p>
  
  <pre><code>string(36) "/usr/local/etc/httpd/htdocs/daikaidk"
  bool(true)
  string(34) "/usr/local/apache2/htdocs/daikaidk"
  bool(true)
  </code></pre>