You are here: Re: How to detect local host? « PHP Programming Language « IT news, forums, messages
Re: How to detect local host?

Posted by Chuck Anderson on 06/05/05 22:02

Daniel Loose wrote:

>Hello,
>
>in order to use my scripts developed at home directly after upload, I
>wish to define a variable $root at begin of each script in a way that
>it always - be it here at home or on any other computer - contains the
>correct path to the web docs directory. How shall I do that the best
>way? (At least, how do I get the local IP or hostname? Or is there an
>environment variable?) Grepped 4 thick books but nothing found...
>
>TIA, Daniel
>
>
If I understand you right, .... what I do is look at the SERVER variable
HTTP_HOST.

if ($_SERVER['HTTP_HOST'] == 'localhost')
{
// the script is running on my home computer and not on the remote server
}
else
{
// $_SERVER['HTTP_HOST'] contains the domain name where my script is running
}

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************

 

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

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