Gets the base URL of the request

The base URL consist of the protocol (http(s)), the domain name and
the port number when using a non standard port. E.g. https://example.com:8080

@return string The base URL
551005
public function getBaseUrl(): string
    {
        $schemeAndHttpHost = 'http';

        if ($this->isEncrypted()) {
            $schemeAndHttpHost .= 's';
        }

        $schemeAndHttpHost .= '://' . $this->server('SERVER_NAME');

        if ((!$this->isEncrypted() && $this->server('SERVER_PORT') !== '80')
            || ($this->isEncrypted() && $this->server('SERVER_PORT') !== '443'))
        {
            $schemeAndHttpHost .= ':' . $this->server('SERVER_PORT');
        }

        return $schemeAndHttpHost;
    }
645765
public function getBaseUrl()
    {
        $baseUrl = $this->innerExtractor->getBaseUrl();
        $siteAccess = $this->masterRequest->attributes->get('siteaccess');
        if ($siteAccess instanceof SiteAccess && $siteAccess->matcher instanceof SiteAccess\URILexer) {
            $baseUrl .= $siteAccess->matcher->analyseLink('');
        }

        return $baseUrl;
    }
1034669
public static function GetUrl () {
		return static::LasyClassVarAccessCallback('url', function () {return sprintf('%s://%s%s%s', strtolower(static::GetCurrnetProtocol()), static::GetDomainName(), static::GetPath(), !empty($query_parameter = static::GetParameters()->getRecursiveArrayCopy()) ? sprintf('?%s', http_build_query($query_parameter)) : '');});
	}
1225172
private static function getBaseUrl()
    {
        if (isset($_SERVER['SERVER_NAME'])) {
            $sProtocol = !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])
                == 'on' ? 'https' : 'http';
            return $sProtocol.'://'.$_SERVER['SERVER_NAME'];
        }
        return null;
    }
1031762
protected function getAssetBaseUrl()
    {
        $baseUrl = $this->hasOption(self::BASE_OPTION_KEY) ? $this->getOption(self::BASE_OPTION_KEY) : ROOT_URL;

        $baseUrl = trim($baseUrl);
        if(substr($baseUrl, -1) != '/'){
            $baseUrl .= '/';
        }

        return $baseUrl;
    }
16451
public function base_uri(){
    	$uri = $this->uri();
		if (($strpos = strpos($uri, '?')) !== false) 
			$uri = substr($uri, 0, $strpos);
		return $uri;
    }
563953
function getBaseUrl()
    {
        $filename       = $this->getServer()->get('SCRIPT_FILENAME', '');
        $scriptName     = $this->getServer()->get('SCRIPT_NAME');
        $phpSelf        = $this->getServer()->get('PHP_SELF');
        $origScriptName = $this->getServer()->get('ORIG_SCRIPT_NAME', false);

        if ($scriptName !== null && basename($scriptName) === $filename) {
            $baseUrl = $scriptName;
        } elseif ($phpSelf !== null && basename($phpSelf) === $filename) {
            $baseUrl = $phpSelf;
        } elseif ($origScriptName !== null && basename($origScriptName) === $filename) {
            // 1and1 shared hosting compatibility.
            $baseUrl = $origScriptName;
        } else {
            // Backtrack up the SCRIPT_FILENAME to find the portion
            // matching PHP_SELF.

            $baseUrl  = '/';
            $basename = basename($filename);
            if ($basename) {
                $path     = ($phpSelf ? trim($phpSelf, '/') : '');
                $baseUrl .= substr($path, 0, strpos($path, $basename)) . $basename;
            }
        }

        // Does the base URL have anything in common with the request URI?
        $requestUri = $this->getMessageObject()->getTarget();

        // Full base URL matches.
        if (0 === strpos($requestUri, $baseUrl))
            return $baseUrl;

        // Directory portion of base path matches.
        $baseDir = str_replace('\\', '/', dirname($baseUrl));
        if (0 === strpos($requestUri, $baseDir))
            return $baseDir;

        $truncatedRequestUri = $requestUri;

        if (false !== ($pos = strpos($requestUri, '?')))
            $truncatedRequestUri = substr($requestUri, 0, $pos);

        $basename = basename($baseUrl);

        // No match whatsoever
        if (empty($basename) || false === strpos($truncatedRequestUri, $basename))
            return '';

        // If using mod_rewrite or ISAPI_Rewrite strip the script filename
        // out of the base path. $pos !== 0 makes sure it is not matching a
        // value from PATH_INFO or QUERY_STRING.
        if (strlen($requestUri) >= strlen($baseUrl)
            && (false !== ($pos = strpos($requestUri, $baseUrl)) && $pos !== 0)
        ) {
            $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
        }

        return $baseUrl;
    }
831400
public function getBaseUrl()
    {
        if ($this->baseUrl) {
            return $this->baseUrl;
        }
        if ($this->baseUrlProvider) {
            return call_user_func($this->baseUrlProvider, $this);
        }

        return $this->baseUrl;
    }
365910
public static function getBaseUrl()
    {
        $protocol = isset($_SERVER['HTTPS']) ? 'https' : 'http';
        $url = $protocol . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];

        // cut at last '/' (we dont want to see index.php)
        return substr($url, 0, strrpos($url, '/'));
    }
341901
public static function base()
    {
        if (! isset(self::$_base)) {
            // Get the base request path
            if (strpos(PHP_SAPI, 'cgi') !== false && !ini_get('cgi.fix_pathinfo')  && !empty($_SERVER['REQUEST_URI'])) {
                // PHP-CGI on Apache with "cgi.fix_pathinfo = 0"
                // We don't have user-supplied PATH_INFO in PHP_SELF
                $path = $_SERVER['PHP_SELF'];
            } else {
                $path = $_SERVER['SCRIPT_NAME'];
            }

            $path = rtrim(dirname($path), '/\\');

            // Sanitize the url since we can't trust the server var
            $path = AnService::get('anahita:filter.url')->sanitize($path);

            self::$_base = AnService::get('anahita:http.url', array('url' => $path));
        }

        return self::$_base;
    }
1083425
public static function url()
    {

        $server = $_SERVER;

        $ssl = (!empty($server['HTTPS']) && $server['HTTPS'] == 'on');

        $sp = strtolower($server['SERVER_PROTOCOL']);

        $protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');

        $port = $server['SERVER_PORT'];

        $port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port;

        $host = isset($host) ? $host : $server['SERVER_NAME'] . $port;

        $host .= preg_replace("/\?.*/", "", $server["REQUEST_URI"]);

        return $protocol . '://' . $host;
    }
212724
public function baseURL() {
		if($this->api_is_https) {
			$url = 'https://' . $this->api_host . ($this->api_port != 443?':'.$this->api_port:'');
		} else {
			$url = 'http://' . $this->api_host . ($this->api_port != 80?':'.$this->api_port:'');
		}
		return $url;
	}
1325726
protected function _getAppBase()
    {
        $baseUrl = Configure::read('App.base');
        if (!$baseUrl) {
            $request = Router::getRequest(true);
            if (!$request) {
                $baseUrl = '';
            } else {
                $baseUrl = $request->base;
            }
        }
        return $baseUrl . '/';
    }
751107
public function url()
    {
        $dirname = $this->parent->url();

        if ($this->parent instanceof Root) { //at root

            return $dirname.$this->basename();
        }

        return sprintf('%s/%s', $dirname, $this->basename());

    }
97774
public static function GetBaseURL()
	{
		$url = self::GetCurrentURL(false);
		$slash = strripos($url,"/");
		return substr($url,0,$slash+1);
	}
1289222
public function getBaseUrl() {
    if ($pos = strpos($this->url, '?')) {
      return substr($this->url, 0, $pos);
    }
    return $this->url;
  }
1341198
public function getAbsoluteUrl(): string
    {
        if (!$this->absoluteUrl) {
            // Guessing we're a http endpoint.
            $this->absoluteUrl = 'http://'.
                ($this->getHeader('Host') ?? 'localhost').
                $this->getUrl();
        }

        return $this->absoluteUrl;
    }