title: Use the required / included file as base directory in PHP
body: <p>I am currently using an index.php to include another file , it structure like:</p>
  
  <pre><code>root / index.php
       / new/ index.php
  </code></pre>
  
  <p>And I use </p>
  
  <pre><code>&lt;?php
  require_once("new/index.php");
  ?&gt;
  </code></pre>
  
  <p>the problem is , all paths in it are wrong. As all paths are based on new/index.php , when i include it, all paths changes to based on index.php. Are there any way to let the outsider visit index.php but at the same time my actual code is stored in new/ folder? Thanks</p>