title: Define root path one time at one place
body: <p>I like to refer images, css and php files using their absolute path, that is starting from root, with an address beginning with "/".</p>
  
  <p>I need to include php files that are all located at "/bin/res/include". I figured out I can't use absolute paths in php as I do in html. After some research I discovered the best method that suits my needs is to</p>
  
  <pre><code>define("PHP_ROOT", "/home/a7503679/public_html/bin/res/include/");
  </code></pre>
  
  <p>and then to include some file</p>
  
  <pre><code>include_once(PHP_ROOT."filename.php");
  </code></pre>
  
  <p>I don't want to paste the first define on every html page. Can I do a global define? Can I define that constant one time at one place and make it known to all html pages? If so, how and where is the <em>global</em> place?</p>
  
  <hr>
  
  <ul>
  <li>I can't use <code>dirname(__FILE__);</code> because that only gives the full path to the folder where I'm currently in, which may not be the root.</li>
  <li>I can't use <code>$_SERVER['DOCUMENT_NAME']</code> because I'm using a shared hosting service.</li>
  </ul>
  
  <hr>
  
  <p>[UPDATE:solution] thx everyone, especially RiaD for its idea, this is what I've done:</p>
  
  <p>Edited my .htaccess file at the root of my website and added the following line,</p>
  
  <pre><code>#Loads an init php located at &lt;fullpath&gt;/&lt;path-to-folder-with-php-files-to-include&gt;/init.php
  php_value auto_prepend_file /home/a7503679/public_html/bin/res/include/init.php
  </code></pre>
  
  <p>Now all my html files will include that init.php file, so you should (as I did) put there all the common php code you'll need on every html page, which in my case was:</p>
  
  <pre><code>&lt;?php
  define("PHP_ROOT", "/home/a7503679/public_html/bin/res/include/"); #this solves the problem
  include 'lang.php'; #translations file
  ?&gt;
  </code></pre>
  
  <p>Before I needed to include that <code>lang.php</code> on every page and now it's automatically done. If I need to include any other php file, using its absolute path, I just type <code>include PHP_ROOT.'filename.php';</code></p>