Re: best way to properly build an include path *regardless* from where I am calling the include?

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

 



On Jul 5, 2009, at 4:42 PM, Kim N. Lesmer wrote:

Like Michael said there is more than one way to deal with this.

I personally prefer to use this:

require_once ($_SERVER['DOCUMENT_ROOT'] . "/incl/myfile.php");

Unless the file needs to be kept outside of where the webserver serves
files.

Kim, this is exactly what I was looking for. I had been over $_SERVER in the docs.. but somehow missed that basic obvious param. Thanks!
Sudeer, Shawn, Michael,
your efforts were not wasted either. I absorbed from you all and came up with:

define('MY_DOC_ROOT', $_SERVER['DOCUMENT_ROOT']);
set_include_path(MY_DOC_ROOT . PATH_SEPARATOR . get_include_path());
include 'MY_php_functions.inc';

which I call with:
include $_SERVER['DOCUMENT_ROOT'] . '/MY_inc_php/incsInAllPages.inc';

really basic stuff.. humbling for me, coming from other languages/ environements where I was more expert. ..lucky me this is such a generous and compassionate group of people here.
Thanks again
-Govinda

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