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

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

 



Hi,

Monday, March 7, 2005, 1:08:27 PM, you wrote:
LG> Hello Tom,

LG> Sunday, March 6, 2005, 6:18:54 PM, you wrote:
TR>> and let me see what it prints

LG> Still not quite there.

LG> Site root
LG> **************
LG> File name: C:\Sambar\docs\test\test.php
LG> Script: /test.php
LG> Document root: C:\Sambar\docs\test\test.php
LG> Base: test.php
LG> Include: C:\Sambar\docs\test\include
LG> OS: winnt
LG> Include: C:\Sambar\docs\test\include;.;C:\php5\pear

LG> **************

LG> Site root/folder1
LG> ***************
LG> File name: C:\Sambar\docs\test\folder1\test.php
LG> Script: /folder1/test.php
LG> Document root: C:\Sambar\docs\test\folder1\test.php
LG> Base: test.php
LG> Include: C:\Sambar\docs\test\folder1\include
LG> OS: winnt
LG> Include: C:\Sambar\docs\test\folder1\include;.;C:\php5\pear

LG> ***************

LG> Site root/folder1/folder2
LG> ***************
LG> File name: C:\Sambar\docs\test\folder1\folder2\test.php
LG> Script: /folder1/folder2/test.php
LG> Document root: C:\Sambar\docs\test\folder1\folder2\test.php
LG> Base: test.php
LG> Include: C:\Sambar\docs\test\folder1\folder2\include
LG> OS: winnt
LG> Include:
LG> C:\Sambar\docs\test\folder1\folder2\include;.;C:\php5\pear

LG> ***************

LG> Thanks.

LG> Cheers,
LG> Leif Gregory 

LG> -- 
LG> TB Lists Moderator (and fellow registered end-user)
LG> PCWize Editor  /  ICQ 216395  /  PGP Key ID 0x7CD4926F
LG> Web Site <http://www.PCWize.com>


Ok I see where is is going wrong, try this:

<?php
if(isset($_SERVER["SCRIPT_FILENAME"])){
        $file_name = str_replace('\\','/',$_SERVER['SCRIPT_FILENAME']);
        echo "File name: $file_name<br>";
        
        $script = str_replace('\\','/',$_SERVER['SCRIPT_NAME']);
        echo "Script: $script<br>";
        
        $document_root = str_replace($script,'',$file_name);
        echo "Document root: $document_root<br>";
        
        $base = basename($document_root);
        echo "Base: $base<br>";
        
        $include = str_replace($base,'include',$document_root);
        echo "Include: $include<br>";
        
        $os = strtolower(PHP_OS);
        echo "OS: $os<br>";

        $lk = ':';
        $org_include = ini_get("include_path");
        if(preg_match('/^win/i',$os))   $lk = ';';
        
        ini_set("include_path",$include.$lk.$org_include);
        echo "Include: ".ini_get("include_path")."<br>";
}

-- 
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