Trouble with / vs ./ vs ../ and absolute and relative paths
<p>I have many PHP files in</p>

<pre><code>/
/client/
/user/
/config/
etc...
</code></pre>

<p>I want all my files to include <code>/user/codestart.php</code>.  (Lots of functions etc)</p>

<p>Therefore:</p>

<ul>
<li>All files in <code>/</code> have <code>include("./user/codestart.php");</code></li>
<li>All files in <code>/user/</code> have <code>include("codestart.php");</code></li>
<li>All files in <code>/client/</code> have <code>include("../user/codestart.php");</code></li>
</ul>

<p>The problem is that <code>/user/codestart.php</code> has <code>include("../config/config.php");</code>  (The MySQL ID and password)</p>

<p>When a file in <code>/</code> runs, such as <code>/index.php</code>, it includes <code>./user/codestart.php</code>. 
Then <code>/user/codestart.php</code> includes <code>../config/config.php</code>, but it cannot see it, because it thinks it is calling it from <code>/</code>, instead of from <code>/user/</code>.</p>

<p>If I change
<code>include("../config/config.php")</code> to be
<code>include("./config/config.php")</code>
that fixes it for <code>/</code> files, but breaks it for<code>/user/</code> and<code>/client/</code> files.</p>

<p>Bottom line is that when one PHP file includes another file, PHP thinks it is operating from the location of the original file, not the calling file.</p>

<p>I need to use relative paths, not absolute paths.  Absolute paths will not work in my situation.</p>

<p>Is there any way to solve this?</p>
