Govinda wrote:
I want something that will work for calling an include from any file
that
lives n levels deep.
That's where you have to define a variable (or constant) that
tells the system where the web root is located, and then use that to
determine where you are in relation to that. For
I'm not sure how this could be made simpler.
$site_root = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
Call that in any file in the root of *your* web directories, and you
have what is essentially the "document root" for *your* site.
Presumably, you know the *relative* directories of all y
On Mon, Jul 06, 2009 at 07:15:03PM -0600, Govinda wrote:
>
> Dan I love to see smart hacks in action! ..and I believe I get what
> you are doing.
> I am just amazed that there is not a SIMPLE (one-liner) reliable way
> of just saying "document root" without a complex function like that.
> I mea
I want something that will work for calling an include from any
file that
lives n levels deep.
That's where you have to define a variable (or constant) that
tells the system where the web root is located, and then use that to
determine where you are in relation to that. For example:
On Mon, Jul 6, 2009 at 18:16, Govinda wrote:
>
> this is great, but then I still do not have a solution that will work for
> any level deep of dir/ .
> I.e. this-
> dirname(dirname(__FILE__))
> gives the correct first part of the path to document root like
> $_SERVER['DOCUMENT_ROOT'] does
> only wh
On Mon, 6 Jul 2009 16:16:55 -0600
Govinda wrote:
> I do not really understand why
> $_SERVER['DOCUMENT_ROOT']
> should return the right data at one time and not at another. (?)
In general it will always provide the right data, but as the manual
says: "The entries in this array ($_SERVER) are cr
On Jul 6, 2009, at 9:24 AM, Daniel Brown wrote:
On Mon, Jul 6, 2009 at 11:04, Govinda
wrote:
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!
And now I'll throw a monkey wrench into the gears an
On Mon, Jul 6, 2009 at 8:24 AM, Daniel Brown 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 a
On Mon, Jul 6, 2009 at 11:04, Govinda wrote:
>
> 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!
And now I'll throw a monkey wrench into the gears and tell you
that, yes, it works, but don't always re
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,
On Sun, 5 Jul 2009 14:33:07 -0600
Govinda wrote:
> I am confusing myself reading the docs just now.
>
> i.e.:
> include_path
> basename()
> and dirname()
>
> I had thought from many months ago that
>
> would include
> somefile.php
> living in
> somedir
> regardless from where in the site str
I am confusing myself reading the docs just now.
i.e.:
include_path
basename()
and dirname()
I had thought from many months ago that
would include
somefile.php
living in
somedir
regardless from where in the site structure I am calling it.
Now it does not seem to be doing that.
What is the sa
12 matches
Mail list logo