You are here: Re[3]: [PHP] Document root, preferred way to find it??? « PHP « IT news, forums, messages
Re[3]: [PHP] Document root, preferred way to find it???

Posted by Tom Rogers on 03/05/05 06:25

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

 

Navigation:

[Reply to this 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

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