Re: best way to properly build an include path *regardless* from where I am calling the include?
| From: | Paul M Foster | Date: | Tue, 07 Jul 2009 01:45:44 +0000 |
| Subject: | Re: best way to properly build an include path *regardless* from where I am calling the include? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-294980@lists.php.net to get a copy of this message | ||
On Mon, Jul 06, 2009 at 07:15:03PM -0600, Govinda wrote:
<snip>
>
> 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 mean what we need here is a global include path for the shared-
> hosted user .. an include_path that can be set for the virtual server
> user and it 'sticks' (does not have to be set on every page load).
> I think I'll let this all go for now... I have a lot of basics to
> cover before I trip out too much in any one area. I'm going to need
> the time and brain juice for some 'real' issues later ;-)
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 M. Foster