Why would I use dirname(__FILE__) in an include or include_once statement?
<p>I have seen this: </p>

<pre><code>&lt;?php
  include( dirname(__FILE__) . DIRECTORY_SEPARATOR . 'my_file.php');
?&gt;
</code></pre>

<p><em>Why would I ever need to do this?</em> Why would I go to the trouble of getting the dirname and then concatenating that with a directory separator, and a new filename? </p>

<p>Is the code above not equivalent to this: </p>

<pre><code>&lt;?php
  include( 'my_file.php' );
?&gt;
</code></pre>

<p>??</p>

<p><a href="http://php.net/manual/en/function.include.php" rel="nofollow">The PHP doc</a> says, </p>

<blockquote>
  <p>Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, <strong>include() will finally check in the calling script's own directory</strong> and the current working directory before failing. The include() construct will emit a warning if it cannot find a file; this is different behavior from require(), which will emit a fatal error.</p>
</blockquote>
