title: Make sure PHP script path is correct if used in other scripts
body: <p>Writing code in PHP, how can I ensure the require_once path of a script is translated correctly regardless of where the calling script is?</p>
  
  <p>Assuming a folder structure of:</p>
  
  <pre><code>ROOT
      {subfolder
      {subfolderX
  </code></pre>
  
  <p>In my "script A" which is in a subfolder called scripts it requires another script in another subfolder called "script B," so my require looks like</p>
  
  <pre><code>require_once("../subfolderX/script B");
  </code></pre>
  
  <p>This all works okay. But if I call script A from another script which is say up a level such as:</p>
  
  <pre><code>require_once("subfolder/script A");
  </code></pre>
  
  <p>The call to script B doesn't work becasue it's now relative to the new calling script.</p>
  
  <p>What is the correct technique here to ensure the path stays relative to the calling script?</p>