note 40562 deleted from reserved.variables by kennyt

From: Date: Mon, 08 Mar 2004 02:16:40 +0000
Subject: note 40562 deleted from reserved.variables by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-66418@lists.php.net to get a copy of this message
Note Submitter: php@frambooz.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.

« previous php.notes (#66418) next »