estelle Posted October 10, 2006 Share Posted October 10, 2006 Hi,Can anyone provide examples of where $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] would differ?The only example I've found is when running on localhost becaues I use a specific port and the two variables come out as:$_SERVER['HTTP_HOST'] --> localhost:10001$_SERVER['SERVER_NAME'] --> localhostAre there occasions where one variable will be blank and the other will be set?TIA :) Link to comment https://forums.phpfreaks.com/topic/23510-when-do-server_name-and-http_host-differ/ Share on other sites More sharing options...
btherl Posted October 10, 2006 Share Posted October 10, 2006 'SERVER_NAME' The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host. 'HTTP_HOST' Contents of the Host: header from the current request, if there is one. Going by that description, SERVER_NAME should be more stable, since it's defined by the web server. HTTP_HOST will probably have more variance.I haven't answered your question, but I hope this helps :) Link to comment https://forums.phpfreaks.com/topic/23510-when-do-server_name-and-http_host-differ/#findComment-106675 Share on other sites More sharing options...
estelle Posted October 10, 2006 Author Share Posted October 10, 2006 Thanks, it does help :)I looked up those descriptions and wasn't really sure about what to make of it. I appreciate your opinion! I'll start by using SERVER_NAME and then if I run into problems i'll consider checking HTTP_HOST. Link to comment https://forums.phpfreaks.com/topic/23510-when-do-server_name-and-http_host-differ/#findComment-107039 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.