Problems with include paths
<p>My <a href="http://stackoverflow.com/questions/7072920/unknown-function-in-php-netbeans-how-to-suppress">previous question</a> broght up some discussion which suggested that I am wrong to use the likes of  </p>

<pre><code>require_once($_SERVER['DOCUMENT_ROOT'] . '/proj/database/database-common.php');
</code></pre>

<p>and should, instead be using </p>

<pre><code>require_once(dirname(__FILE__) . '/database/database-common.php');
</code></pre>

<p>BUT, I have a multi-level hierarchy and some common functionality (dataebase, error handling, etc) which can be called from any level - how do I handlt that? E.g, my error handling requires a CSS file from $_SERVER['DOCUMENT_ROOT']\css\my.css</p>

<p>If I do not have <code>$_SERVER['DOCUMENT_ROOT']</code> as an anchor point, can I use something else? If not, how do I handle that a common file may wish to include another, but does not know from which level it itself is being included?</p>

<p>E.g.:  </p>

<pre><code>root
     `- databse
      `- validation
</code></pre>

<p>If validation/common.php wants to include database/database_common.php thhen, without an anchor, validation/common.php cannot know the path to database_common.php It is <em>not</em> <code>..\database/database_common.php</code> if validation/common.php was incldued from a file in the root directory (and this is a simplified example)</p>

<p>My philiosophy is to always require a file in the file which uses it, so I can't just include everthing in the root directory files ....</p>

<p>Can someoen clarify best pracise on this for me?  Thanks</p>
