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]

 



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 your files.
Simply append those relative directories + filenames to the $site_root
variable, and you're done.

Paul

Paul, you are right.  what you say above is very simple.
I guess I just did a poor job of communicating what I was after.
What I wanted was:
($_SERVER['DOCUMENT_ROOT']
..but an equivelent that would work on any server, even if ($_SERVER['DOCUMENT_ROOT'] was turned off. SO that I could build a universal global include path that would not break in any page, even if I later moved the page up or down a directory.. never requiring editing, despite the page's URL changes.

-G

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