PHP include(): Use case for include from original script's PWD
<p>When using PHP's <code>include()</code> and <code>require()</code> functions to include a file which in turn includes another file, the PWD (relative reference) for the second file's <code>include()</code> is the directory for the original script location (the first script in the stack as called by Apache), not for the current file. What is the design decision behind that, and what is the use-case?</p>

<p>For instance, suppose a generic database-connection class defined in <code>~/public_html/classes/database.php</code> which stores its configuration data (usernames, passwords) out of the web root in <code>~/config.php</code>. The author of the database configuration class would logically call the config file with the relative filename <code>../../config.php</code>. However, this does not work as expected because the PWD is not of the <code>database.php</code> file but rather of the file which included it, which could be <code>~/public_html/index.php</code>, <code>~/public_html/someDir/somePage.php</code> or elsewhere.</p>

<p>I know to work around this by getting the directory of the current file with <code>dirname(__FILE__)</code>. However, I cannot think of a single use case where I would want <code>require()</code> or <code>include()</code> to be relative to the original script location. What is the use case for it being as it is?</p>
