If you must use $_SERVER['DOCUMENT_ROOT'] and if you have no control over the configuration of Apache or PHP, you could use the following hack to ensure that it always has the trailing slash:
$_SERVER['DOCUMENT_ROOT'] .= (substr($_SERVER['DOCUMENT_ROOT'],-1)=='/')?'':'/'; Thanks, Nathan. http://control.kennedytechnology.com From: [email protected] [mailto:[email protected]] On Behalf Of Aaron Cooper Sent: Tuesday, 17 March 2009 4:12 p.m. To: [email protected] Subject: [phpug] DOCUMENT_ROOT trailing slash Hi all, We have a new dedicated server and $_SERVER['DOCUMENT_ROOT'] is returning the correct document root with no trailing slash. On all our old servers, it would return it with a trailing slash. So we have alot of sites that require a bit of adjustment for this new box Is this configurable and would it be managed by php.ini or Apache? Arguments for and against the trailing slash (or another more portable way of obtaining the docroot) is welcome. Cheers Aaron --~--~---------~--~----~------------~-------~--~----~ NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected] -~----------~----~----~----~------~----~------~--~---
