What is the difference between HTTP_HOST
and SERVER_NAME
in PHP?
where:
HTTP_HOST
=== $_SERVER[\'HTTP_HOST\'
As balusC said SERVER_NAME is not reliable and can be changed in apache config , server name config of server and firewall that can be between you and server.
Following function always return real host (user typed host) without port and it's almost reliable:
function getRealHost(){
list($realHost,)=explode(':',$_SERVER['HTTP_HOST']);
return $realHost;
}