Ergo\Http\Url::getHostRelativeUrl PHP Method

getHostRelativeUrl() public method

The URL components after the host.
public getHostRelativeUrl ( ) : string
return string
    public function getHostRelativeUrl()
    {
        $url = $this->getPath();
        if ($this->hasQueryString()) {
            $url .= '?' . $this->getQueryString();
        }
        if ($this->hasFragmentString()) {
            $url .= '#' . $this->getFragmentString();
        }
        return $url;
    }

Usage Example

Beispiel #1
0
 public function testBriefHttpUrlUsage()
 {
     $url = new Http\Url('http://example.org/');
     $this->assertEquals($url->getHostRelativeUrl(), '/');
     $this->assertEquals($url->getSchemeRelativeUrl(), '//example.org/');
 }