Prado\Web\THttpRequest::getBaseUrl PHP Method

getBaseUrl() public method

public getBaseUrl ( $forceSecureConnection = null ) : string
return string schema and hostname of the requested URL
    public function getBaseUrl($forceSecureConnection = null)
    {
        $url = $this->getUrl();
        $scheme = $forceSecureConnection ? "https" : ($forceSecureConnection === null ? $url->getScheme() : 'http');
        $host = $url->getHost();
        if ($port = $url->getPort()) {
            $host .= ':' . $port;
        }
        return $scheme . '://' . $host;
    }

Usage Example

Exemplo n.º 1
0
 public function testGetBaseUrl()
 {
     $request = new THttpRequest();
     $request->init(null);
     self::assertEquals('http://localhost', $request->getBaseUrl());
 }