Working with paths - make a SITE_ROOT constant available on each page
<p>I am a php newb and I am struggling with paths.</p>

<p>I have a config.php file in the root of my application where I have defined a constant which stores the parent's directory path.</p>

<pre><code>define("SITE_ROOT", realpath(dirname(__FILE__)));
</code></pre>

<p>The site will have different folders:
/includes/
/admin/
/theme/</p>

<p>Now, even if the SITE_ROOT constant is global, I understand that the global declaration is declared only until that script ends.</p>

<p>So for example, if I echo SITE_ROOT in admin.php, I will get a php error because I haven't included config.php into admin.php.</p>

<p><strong>Now, is there a way to skip including config.php in each and every file and make my SITE_ROOT constant available everywhere?</strong></p>

<p>TY very much! :)</p>
