If my URL is http://www.server.com/myapp/stuff/to/see
and my directory structure on disk is htdocs/myapp/*
, how can I extract the /myapp
For the web root, there is DOCUMENT_ROOT
as pointed out in several answers. For the application root, there is no way for the system to tell which folder in your application is the root folder. You will have to set that manually.
Most applications define an application root using dirname(__FILE__);
or a config setting and store that in a constant that is available throughout the application.