title: Absolute (or relative?) path in PHP
body: <p>Sorry for asking it as it may be answered many times before, but my question is little bit different </p>
  
  <p>I have tree like </p>
  
  <pre><code>/var/www/path/to/my/app/
     -- index.php
     -- b.php
     -- inc/
        -- include.php
  </code></pre>
  
  <p>(I'm accessing inc/include.php from index.php,</p>
  
  <pre><code>include "inc/include.php";
  </code></pre>
  
  <p>)</p>
  
  <p>but in include.php, I need to get absolute path to APPLICATION root, not DOCUMENT_ROOT
  so in result, I need to be able to use this command</p>
  
  <pre><code>//inc/include.php
  include(APP_ROOT."/b.php");
  </code></pre>
  
  <p>repeating, I do NOT WANT TO CALL IT LIKE </p>
  
  <pre><code>include("../b.php");
  </code></pre>
  
  <p>is there native function, if possible?</p>
  
  <h1>UPDATE:</h1>
  
  <p>I am wanting to get PATH by PHP as any open source need to have this path detection
  why? If I would want to include inc/include.php from ajax/1/somethiing.php, it success but inc/include.php then tries to include ajax/b.php instead of b.php</p>
  
  <h1>For Pekka:</h1>
  
  <p>I have this tree</p>
  
  <pre><code>-- index.php
  -- b.php
  -- inc/
      -- include.php
  -- ajax/
      -- 1/
         -- ajax.php
  </code></pre>
  
  <p>Now look. From index.php, you'll call inc/include.php</p>
  
  <pre><code>include("inc/include.php"); //included file
  </code></pre>
  
  <p>now, included file searchs for</p>
  
  <pre><code>include("../b.php");
  </code></pre>
  
  <p>It will work, but! If I would call include of inc/include.php from ajax/1/ajax.php, like this</p>
  
  <pre><code>include("../../inc/include.php");
  </code></pre>
  
  <p>it will work, but included file will try to include</p>
  
  <pre><code>../b.php 
  </code></pre>
  
  <p>instead of 
      ../../b.php as path is relative to file which INCLUDED that inc/include.php
  Got it ?</p>