PHP

Determining Application Root in PHP

I have always had trouble reliably and dynamically finding what my application root was in PHP. There seemed no way to effectively determine what the application root was on the fly. I always keep my application root separate from my www root for security considerations. This knocks out using $_SERVER['DOCUMENT_ROOT'].

The Issue

Consider the following directory structure:

/path/to/domain.com
  --> app/
        --> includes/main.php        
  --> www/
        --> index.php
        --> admin/index.php
Syndicate content