I'm trying to access the DOCUMENT_ROOT variable as listed under the _SERVER superglobal in the PHP manual. I keep getting the Undefined index error no matter what I do. I have tried both $_SERVER['DOCUMENT_ROOT'] and $DOCUMENT_ROOT (with registar_globals switched on).
I can access other _SERVER variables. I treid PHP_SELF and PATH_TRANSLATED which both worked fine. I'm completely stumped, has anyone else come across a similar problem or can think of a reason why this might be happening?
DOCUMENT_ROOT - Undefined index
Moderator: General Moderators
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
This is what I use, I set my own constant HOMEFS and this works on either:
Code: Select all
if (isset($_SERVERї'DOCUMENT_ROOT'])) define('HOMEFS', $_SERVERї'DOCUMENT_ROOT']);
else define('HOMEFS', str_replace(str_replace(""e;, "//",$_SERVERї'PATH_INFO']), "", str_replace("\"e;, "/",$_SERVERї'PATH_TRANSLATED'])));