I'm trying to dynamically adjust the path for one of my scripts using
this:
$script_path = str_replace( $_SERVER['DOCUMENT_ROOT'], "",
dirname(realpath(__FILE__)) ) . DIRECTORY_SEPARATOR;
The problem: the server I'm currently testing it on returns for
$_SERVER['DOCUMENT_ROOT'] something like the path "home/user/path/" and
for __FILE__ "home2/user/path/scriptdir/" I tried to trace the
discrepancy running phpinfo, but the only reference I can find to
"home2" there is _ENV["PWD"].
Anyway, this is throwing all my best laid plans into confusion. Can
someone help me understand why $_SERVER['DOCUMENT_ROOT'] and __FILE__
are returning different basepaths?
And how I might get my script to do what I'd like it to do (basically,
return the directory path of my script minus the document root so that
I can then append it to the absolute URL)?
Hope this makes sense. Thanks,
Tom