Ok, no, this is not a dupe or at least it is not answered. I want to know the url to the currently executing script's directory.
Any answer involving $_SERVER['REQUEST_URI'], et al is (likely) off topic.
I have a script at /blah/blah/public_html/foo/bar/thescript.php
. This script is included by other scripts. My browser is not at http://domain.com/foo/bar/thescript.php.
What I want is /foo/bar
or http://domain.com/foo/bar
I came up with:
$dir = str_replace($_SERVER['DOCUMENT_ROOT'],'', __DIR__);
It works, ok. Just checking for other solutions.
Ok, yep, its a dupe. here is another way. (very much the same as what i came up with
$dir = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']));