If you want this behaviour at the server level, you can use mod_dir with
the DirectorySlash directive. The details are in the Apache server
documentation.
Regards,
Carlos
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.