title: php includes is there any way to include a file relative only to that document?
body: <p>If I have an index.php file that includes inc/footer.php I would write:</p>
  
  <pre><code>include 'inc/footer.php';
  </code></pre>
  
  <p>If I want to include another file inside footer.php, I must do it relative to the index.php file (the one that is including it). This may not be a problem, but what about if I want to include index.php from an entire different location?</p>
  
  <p>I understand that there are several methods to achieve this like defining an absolute path or using <code>dirname(__FILE__)</code>.</p>
  
  <p>This is something that has never been a real problem since one way or another I always figured it out but that I always wondered how exactly includes work in php.</p>
  
  <p>Can someone explain me exaclty what is going on under the hood?</p>