mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进Request类的host方法 支持仅仅获取host而不包含端口号
This commit is contained in:
@@ -1342,14 +1342,18 @@ class Request
|
||||
/**
|
||||
* 当前请求的host
|
||||
* @access public
|
||||
* @param bool $strict true 仅仅获取HOST
|
||||
* @return string
|
||||
*/
|
||||
public function host()
|
||||
public function host($strict = false)
|
||||
{
|
||||
if (isset($_SERVER['HTTP_X_REAL_HOST'])) {
|
||||
return $_SERVER['HTTP_X_REAL_HOST'];
|
||||
$host = $_SERVER['HTTP_X_REAL_HOST'];
|
||||
} else {
|
||||
$host = $this->server('HTTP_HOST');
|
||||
}
|
||||
return $this->server('HTTP_HOST');
|
||||
|
||||
return true === $strict ? strstr($host, ':', true) : $host;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user