framework/web/Request.php
public function getHostName()
    {
        if ($this->_hostName === null) {
            $this->_hostName = parse_url($this->getHostInfo(), PHP_URL_HOST);
        }

        return $this->_hostName;
    }
public function getHostName()
    {
        if ($this->_hostName === null) {
            $this->_hostName = parse_url($this->getHostInfo(), PHP_URL_HOST);
        }

        return $this->_hostName;
    }
Returns the host part of the current request URL.
Value is calculated from current [[getHostInfo()|hostInfo]] property.

> Warning: The content of this value may not be reliable, dependent on the server
> configuration. Please refer to [[getHostInfo()]] for more information.

@return string|null hostname part of the request URL (e.g. `www.yiiframework.com`)
@see getHostInfo()
@since 2.0.10