How can I get the "application root" of my URL from PHP?
<p>If my URL is <code>http://www.server.com/myapp/stuff/to/see</code> and my directory structure on disk is <code>htdocs/myapp/*</code>, how can I extract the <code>/myapp</code> part? Also, what if there was no application folder and the application root was just '/'? Is there a predefined variable for getting that value?</p>

<p>What I want is a function that is able to trim <code>/myapp</code> off of the request URI, so that I'm only left with <code>/stuff/to/see</code>. AND, if I were to move the application to the server document root, have it determine that as well (so that <code>/stuff/to/see</code> is just returned as <code>/stuff/to/see</code>)</p>

<p>My directory structure is this:</p>

<pre><code>application
  |-config
    |-config.inc.php
library
  |-autoload.class.php
public
  |-css
  |-img
index.php
</code></pre>

<p>So, from index.php, I want to know how to get what I asked above.</p>
