CakeRequest::host PHP Method

host() public method

Get the host that the request was handled on.
public host ( boolean $trustProxy = false ) : string
$trustProxy boolean Whether or not to trust the proxy host.
return string
    public function host($trustProxy = false)
    {
        if ($trustProxy) {
            return env('HTTP_X_FORWARDED_HOST');
        }
        return env('HTTP_HOST');
    }

Usage Example

Esempio n. 1
0
 /**
  * test host retrieval.
  *
  * @return void
  */
 public function testHost()
 {
     $_SERVER['HTTP_HOST'] = 'localhost';
     $request = new CakeRequest('some/path');
     $this->assertEquals('localhost', $request->host());
 }
All Usage Examples Of CakeRequest::host