Page 1 of 1
$_SERVER['HTTP_HOST'] returning blanks
Posted: Thu Dec 12, 2002 10:41 am
by PingLeeQuan
I have 2 server that run the same code. The code uses 2 deferent databases depending on which server the code is hosted (i.e. test and production). I used the $_SERVER['HTTP_HOST'] to find the server in question but my echo kept returning blank. I checked the register_globals and it is turned on
any ideas
thanks
--quan
Posted: Thu Dec 12, 2002 12:13 pm
by Johnm
We do the same thing based on the $HTTP_SERVER_VARS['SERVER_NAME'].
John M
Posted: Thu Dec 12, 2002 12:32 pm
by Rob the R
Very strange. Does "phpinfo();" show that HTTP_HOST is blank, too?
Posted: Thu Dec 12, 2002 12:44 pm
by PingLeeQuan
OK... I am confused.. I thought the manual said the $HTTP_SERVER_VARS is deprecated and that we should be using the $_SERVER.
I ran phpinfo(); and i got the right stuff in the server name parameter
I also ran $HTTP_SERVER_VARS['SERVER_NAME'] I also got the right result.
I guess I was going by what the manual was saying
Thanks guys...
this is what the manual said
PHP Superglobals
$GLOBALS
Contains a reference to every variable which is currently available within the global scope of the
script. The keys of this array are the names of the global variables. $GLOBALS has existed since PHP
3.
$_SERVER
Variables set by the web server or otherwise directly related to the execution environment of the
current script. Analogous to the old $HTTP_SERVER_VARS array (which is still available, but
deprecated).
Posted: Thu Dec 12, 2002 1:01 pm
by Rob the R
What version of PHP are you running? The "_SERVER" superglobal is only available for PHP 4.1.0 and later.
Also, you mentioned that "SERVER_NAME" on your phpinfo() page was correct. What about "HTTP_HOST" on the phpinfo() page? Are both present and equal?
I agree with you - I wouldn't want to use deprecated globals if I could help it.
Posted: Thu Dec 12, 2002 4:44 pm
by PingLeeQuan
Rob: You got a point there i am using PHP 4.0.4.pl1... all the information the phpinfo() function produced is correct...
I guess i was having such a problem because of the version number.
Thanks again Rob / john M
--quan