You are here: Re: Better way of swapping between localhost and server? « PHP Programming Language « IT news, forums, messages
Re: Better way of swapping between localhost and server?

Posted by Jerry Stuckle on 09/12/06 20:58

elyob wrote:
> "Peter Fox" <peterfox@eminent.demon.co.uk.not.this.bit.no.html> wrote in
> message news:GCpotVA1vtBFFwX1@eminent.demon.co.uk...
>
>>Following on from elyob's message. . .
>>
>>>Hi,
>>>I am currently developing on a windows XP machine and upload my code via
>>>subversion to a linux server. All was great, until I just tried to test
>>>out
>>>using Zend Studio.
>>>
>>>if ($_SERVER['REMOTE_ADDR']=="127.0.0.1") {
>>>$base_path="../path/";
>>>}
>>>else {
>>>$base_path="/home/account/public_html/path/";
>>>}
>>
>>Base your switch on where the host is (ie what you're _really_ trying to
>>switch on) not on who's calling.
>>
>>eg (but many alternatives) $_ENV['COMPUTERNAME']
>>or
>>$_SERVER['SERVER_NAME']
>>
>>Server name will be localhost when running locally.
>
>
> Yup, that's a better way. However it still doesn't work in Zend Studio ....
>
> Same error .. "Notice: D:\htdocs\\foo.php line 12 - Undefined index:
> SERVER_NAME"
>
>
>

Are you trying to run this directly under Zend Studio instead of from a
web server? If so, your $_SERVER variables won't be set.

You could get by with

if (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] ==
'whatever')

But you'll probably run into other problems, also (i.e. $_POST variables
not set, etc.).





--
==================
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

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