Re[3]: [PHP] Document root, preferred way to find it???
| From: | Tom Rogers | Date: | Sat, 05 Mar 2005 04:25:52 +0000 |
| Subject: | Re[3]: [PHP] Document root, preferred way to find it??? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-210062@lists.php.net to get a copy of this message | ||
Hi,
TR> This will set the include path just before the document root:
TR> if(isset($_SERVER["SCRIPT_FILENAME"])){
TR> $root = $_SERVER['SCRIPT_FILENAME'];
TR> //echo "Root: $root<br>";
TR> $script = $_SERVER['SCRIPT_NAME'];
TR> $document_root = str_replace($script,'',$root);
TR> //echo "Document root: $document_root<br>";
TR> $base = basename($document_root);
TR> //echo "Base: $base<br>";
TR> $include = str_replace($base,'include',$document_root);
TR> //echo "Include: $include<br>";
TR> $os = strtolower(PHP_OS);
TR> //echo "OS: $os<br>";
TR> $lk = ':';
TR> $org_include = ini_get("include_path");
TR> if(preg_match('/^win/i',$os)) $lk = ';';
TR> ini_set("include_path",$include.$lk.$org_include);
TR> //echo "Include:
TR> ".ini_get("include_path")."<br>";
TR> }
TR> --
TR> regards,
TR> Tom
Forgot to tell you to put it in the auto_prepend file and it will work
for all files :)
--
regards,
Tom