标签:static else ati turn === server host lse public
当端口是80的时候,他们的内容是一样的。
但是当端口不是80的时候,就不一样了。
# HTTP_HOST = SERVER_NAME:SERVER_PORT
/**
* 获取当前的host
*/
public static function getSelfHost() {
# HTTP_HOST = SERVER_NAME:SERVER_PORT
$host = 'http://'.$_SERVER['HTTP_HOST'].'/';
return $host;
}
/**
* 获取当前的host
*/
public static function getHttpHost() {
if ((int)$_SERVER['SERVER_PORT'] === 80) {
$host = 'http://'.$_SERVER['SERVER_NAME'].'/';
} else {
$host = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].'/';
}
return $host;
}
上面的代码功能一致 !!!
标签:static else ati turn === server host lse public
原文地址:https://www.cnblogs.com/jiqing9006/p/11027526.html