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
http://www.server.com/myapp/stuff/to/see
htdocs/myapp/*
/myapp
Try this:
echo dirname(__FILE__);
where __FILE__ is the name of current executing script, and dirname gets folder/application folder out of it.
__FILE__
dirname
More Options:
echo $_SERVER['DOCUMENT_ROOT']; // gives you the root dir
On PHP.net