Re[3]: Document root, preferred way to find it???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: ".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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux