Re: best way to properly build an include path *regardless* from where I am calling the include?
| From: | Govinda | Date: | Mon, 06 Jul 2009 15:04:58 +0000 |
| Subject: | Re: best way to properly build an include path *regardless* from where I am calling the include? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-294956@lists.php.net to get a copy of this message | ||
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