note 40563 deleted from reserved.variables by aidan
| From: | aidan@php.net | Date: | Mon, 13 Sep 2004 07:38:46 +0000 |
| Subject: | note 40563 deleted from reserved.variables by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76593@lists.php.net to get a copy of this message | ||
Note Submitter: php at frambooz dot com
----
If you want to dynamically set the $_SERVER["DOCUMENT_ROOT"] variable (which is nescessary
on IIS servers, for instance), try this bit of code (formatting added for clarity):
<?
$_SERVER["DOCUMENT_ROOT"] = str_replace(
$_SERVER["PATH_INFO"],
"",
ereg_replace(
"[\][\]",
"/",
$_SERVER["PATH_TRANSLATED"]
)
)."/";
?>
It will take the full server-path to the script ($_SERVER["PATH_INFO"]), removes the path
to the script relative to the web-root ($_SERVER["PATH_TRANSLATED"]) and formats it using
forward slashes (C:/inetpub/...) which will work on both unix and windows systems.
Took a bunch of headaches away for me.