|
Posted by Chris on 05/10/06 18:30
Thank you Andy. We're not using Apache...the current system is Linux, but
they have given me a Windows 2003 Server for a testing server. It just
seems to think of the document_root as the current folder that the document
resides in. Is there a change I need to make in the php.ini file?
Chris
"Andy Jeffries" <news@andyjeffries.co.uk> wrote in message
news:pan.2006.05.09.19.51.02.30610@andyjeffries.co.uk...
> On Tue, 09 May 2006 12:06:06 -0700, Chris wrote:
>> I'm working on a large intranet group site with a lot of pages, file
>> types, folders, subfolders, etc. I am using the include
>> ('../includes/file.php') , but I would like to have a single snippet that
>> will work for all .php/.html pages in all subfolders. I have seen the
>> $_SERVER['DOCUMENT_ROOT'] indicated as a way to access the root of the
>> website without using ../ for each folder you have to pass up through.
>
> How about I give you a different way... In your Apache VirtualHost use:
>
> php_value include_path .:/path/to/webroot/parent/includes/
>
> Then you can just use:
>
> include("file.php");
>
> From anywhere and it will include it from the current folder (if found),
> if not look in your /includes folder for it.
>
> Anyway, you can do it by parsing $_SERVER["DOCUMENT_ROOT"] to get to the
> parent, but it's much easier (and cleaner to read) by re-setting
> include_path.
>
> If you want to keep the current path you could do it using a single global
> file which ini_set's the include_path to include the current include_path
> and the new /includes folder. You could include that in your Apache
> virtualhost using:
>
> php_value auto_prepend_file /path/to/webroot/parent/includes/global.php
>
> Hope this helps.
>
> Cheers,
>
>
> Andy
>
>
> --
> Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
> http://www.gphpedit.org | PHP editor for Gnome 2
> http://www.andyjeffries.co.uk | Personal site and photos
>
[Back to original message]
|