Re: best way to properly build an include path *regardless* from where I am calling the include?
| From: | Michael Shadle | Date: | Mon, 06 Jul 2009 15:29:10 +0000 |
| Subject: | Re: best way to properly build an include path *regardless* from where I am calling the include? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-294962@lists.php.net to get a copy of this message | ||
On Mon, Jul 6, 2009 at 8:24 AM, Daniel Brown<parasane@gmail.com> wrote:
> Conversely, using the code example from above (and building upon
> it), we know that __FILE__ remains static regardless of the point of
> the call. Thus, it's a better and more reliable method, and is usable
> even if $_SERVER data is not available to the script.
+1 - i use dirname(__FILE__) everywhere. Rasmus said "you can just use
./includes/foo.php, why have an extra function call" (the dirname) but
i tried that on one of my setups and what is odd is it couldn't find
the files from the forced relative paths which should work just fine.
there could have been other weird voodoo going on too, but i know for
a fact dirname(__FILE__) has been reliable and the best part is it
does not require $_SERVER.