Re: include() problem
| From: | David Grant | Date: | Mon, 09 Jan 2006 15:46:50 +0000 |
| Subject: | Re: include() problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-228328@lists.php.net to get a copy of this message | ||
Nuno,
Have you considered $_SERVER['DOCUMENT_ROOT']?
David
Nuno Trancoso wrote:
> This may sound dumb, but i have been up all night going through
> php/apache docs, and still have not found an answer..
>
> Throughout a site i need to include files that are scattered in subdirs,
> sometimes up in the dir tree, sometimes down. Bad design i know but i
> have to live w/ it...
>
> Problem is in the way Apache/PHP see stuff. If i include /somefile.htm
> in html, it means somefile.htm wich is at site root dir. In PHP it looks
> like it means somefile.htm at SERVER root dir.
>
> I can use getcwd() and go around truncating/adding to the string until i
> get a path to use with set_include_path() to add the site root dir to
> the include path, but it just seems wrong to waste cycles doing it...
>
> So, question is, is there a more direct/elegant way to add the site root
> (or any other dir for that matter) to the include path?
>
> TIA
> Nuno Trancoso
>
--
David Grant
http://www.grant.org.uk/