php 获取host地址
/**
* HTTP_HOST = SERVER_NAME:SERVER_PORT
* 获取当前的host
*/
public static function getSelfHost() {
setlog($_SERVER,$_SERVER['HTTP_HOST'],$_SERVER['SERVER_NAME'],'server.log');
$port = $_SERVER['SERVER_PORT'];
$http_host = $_SERVER['HTTP_HOST'];
if ($port == 80 || $port == 443) {
$host = 'http://' . $http_host . '/';
} else {
$host = 'http://'. $http_host .':'.$port.'/';
}
// $host = 'http://' . $http_host . '/';
return $host;
}