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

Your name:

Reply:


Posted by Tom Rogers on 03/07/05 07:00

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация