I recently moved to a new hosting provider and noticed intermittent errors in my php program as a direct result of $_SERVER['DOCUMENT_ROOT'] returning the incorrect path. Instead of returning the path of the current php script, it returns the parent path. As previously mentioned, this behavior was intermittent and was not easily reproduced. After Googling around and doing a lot of testing, it appears that this behavior may be related to my new hosts server config. Specifically, when an "Alias" has been used to map different parts of the file system. I believe I corrected the problem by replacing:
$_SERVER['DOCUMENT_ROOT']
with
substr(FILE, 0, strrpos(FILE, "/"))
Has anyone run across this issue?