You are here: Re: use of $_SERVER['DOCUMENT_ROOT']. « PHP Programming Language « IT news, forums, messages
Re: use of $_SERVER['DOCUMENT_ROOT'].

Posted by Jerry Stuckle on 05/10/06 19:58

Chris wrote:
> 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
>>
>
>
>

Chris,

That's interesting.

I just created a file containing <?php phpinfo(); ?> in the root directory of my
IIS test machine. It shows $_SERVER['DOCUMENT_ROOT'] to be the path to the root
directory of my website - as expected.

Then I moved the file to a subdirectory (actually tried three different ones at
different levels). In each case phpinfo showed the document root to be the root
of the website.

This happens to be Windows 2000 instead of Windows 2003. PHP is loaded as an
isapi module (which does make a difference).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация