Returns the port of this request as string.
@return string
172021
public static function getPort() :? int
  {
      // Check for proxy first
      if (isset($_SERVER['HTTP_X_FORWARDED_PORT'])) {
          return (int) $_SERVER['HTTP_X_FORWARDED_PORT'];
      }
      if ('https' === ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '')) {
          return 443;
      }

      return isset($_SERVER['SERVER_PORT']) ?
        (int) $_SERVER['SERVER_PORT'] : null;
  }
262272
public function getUrlHost()
    {
        $host = '';
        
        if (!empty($_SERVER['HTTP_FORWARDED'])) {
            extract($this->parseForwardedString($_SERVER['HTTP_FORWARDED']));
        }
        
        if (empty($host)) {
            if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
                $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
            } elseif (!empty($_SERVER['HTTP_HOST'])) {
                $parts = explode(':', $_SERVER['HTTP_HOST']);
                $host = $parts[0];
            } elseif (!empty($_SERVER['SERVER_NAME'])) {
                $host = $_SERVER['SERVER_NAME'];
            } else {
                $host = 'unknown';
            }
        }
        
        return $host;
    }
910571
public function getHeadersAsString()
    {
        $headerString = '';
        foreach ($this->getHeaders() as $name => $header) {
            // build up a header string
            $headerString .= $name . ': ' . $header . PHP_EOL;
        }

        return $headerString;
    }
147520
public function toString()
    {
        $request = sprintf('%s %s HTTP/%s', $this->getMethod(), (string) $this->getUrl(), $this->getVersion());

        $str = trim($request) . "\r\n";
        $str .= $this->getHeaders();
        $str .= "\r\n";
        $str .= $this->getContent();
        return $str;
    }
858641
protected function getBaseUrl()
    {
        $port = '';
        if ($this->requestContext->getScheme() === 'https' && $this->requestContext->getHttpsPort() != 443) {
            $port = ":{$this->requestContext->getHttpsPort()}";
        }

        if ($this->requestContext->getScheme() === 'http' && $this->requestContext->getHttpPort() != 80) {
            $port = ":{$this->requestContext->getHttpPort()}";
        }

        $baseUrl = $this->requestContext->getBaseUrl();
        if (substr($this->requestContext->getBaseUrl(), -4) === '.php') {
            $baseUrl = pathinfo($this->requestContext->getBaseurl(), PATHINFO_DIRNAME);
        }
        $baseUrl = rtrim($baseUrl, '/\\');

        return sprintf(
            '%s://%s%s%s',
            $this->requestContext->getScheme(),
            $this->requestContext->getHost(),
            $port,
            $baseUrl
        );
    }
681302
public function toString()
    {
        $result = '';

        if (!empty($this->scheme)) {
            $result.= $this->scheme . ':';
        }

        if (!empty($this->authority)) {
            $result.= '//' . $this->authority;
        }

        $result.= $this->path;

        if (!empty($this->query)) {
            $result.= '?' . $this->query;
        }

        if (!empty($this->fragment)) {
            $result.= '#' . $this->fragment;
        }

        return $result;
    }
101515
private function getConnectionString() {
        $parameters = array(
            'host='             . $this->getHost(),
            'connect_timeout='  . $this->getConnectTimeout(),
            'user='             . $this->getUserName(),
        );
        $this->hasPort()        && $parameters[] = 'port='      . $this->getPort();
        $this->hasPassword()    && $parameters[] = 'password='  . $this->getPassword();
        $this->hasDatabase()    && $parameters[] = 'dbname='    . $this->getDatabase();

        return implode(' ', $parameters);
    }
908498
public function toString()
	{
		$lines	= array();
		$lines[]	= $this->protocol.'/'.$this->version.' '.$this->status;							//  add main protocol header
		$lines[]	= $this->headers->toString();													//  add header fields and line break
		if( strlen( $this->body ) )																	//  response body is set
			$lines[]	= $this->body;																//  add response body
		return join( "\r\n", $lines );																//  glue parts with line break and return result
	}
881935
public function toString()
    {
        $result = "";
        if ($this->scheme) {
            $result .= $this->scheme.'://';
        }
        if ($this->user) {
            $result .= $this->user;
            if ($this->pass) {
                $result .= $this->user;
            }
            $result .= '@';
        }
        if ($this->host) {
            $result .= $this->host;
        }
        if ($this->port) {
            $result .= ':'.$this->port;
        }
        if ($this->pathSegments) {
            $result .= '/'.implode('/', $this->pathSegments);
        }
        if ($this->parameters) {
            $result .= '?'.http_build_query($this->parameters);
        }
        if ($this->fragment) {
            $result .= '#'.$this->fragment;
        }
        return $result;
    }
1302168
public function toString()
    {
        if (empty($this->stringRepresentation)) {
            $this->stringRepresentation = sprintf('%s%s_%s', static::MESSAGE_TO_STRING_PREFIX, $this->getSourceId(), $this->getResourceId());
        }
        return $this->stringRepresentation;
    }
536497
private function getServerString(): string
    {
        return \sprintf(
            '{%s%s%s}',
            $this->hostname,
            '' !== $this->port ? ':' . $this->port : '',
            $this->flags
        );
    }
77520
public static function getURI()
    {
        $s = $_SERVER;
        $ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on');
        $sp = strtolower(array_get($s, 'SERVER_PROTOCOL', 'http://'));
        $protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
        $port = array_get($s, 'SERVER_PORT', '80');
        $port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port;
        $host = (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : array_get($s, 'SERVER_NAME', 'localhost'));
        $host = (strpos($host, ':') !== false) ? $host : $host . $port;

        return $protocol . '://' . $host;
    }
214904
public function getHost() : string
    {
        $host = null;

        if ($this->isUsingTrustedProxy() && $this->headers->has(self::$trustedHeaderNames[RequestHeaders::CLIENT_HOST])) {
            $hosts = explode(',', $this->headers->get(self::$trustedHeaderNames[RequestHeaders::CLIENT_HOST]));
            $host = trim(end($hosts));
        }

        if ($host === null) {
            $host = $this->headers->get('HOST');
        }

        if ($host === null) {
            $host = $this->server->get('SERVER_NAME');
        }

        if ($host === null) {
            // Return an empty string by default so we can do string operations on it later
            $host = $this->server->get('SERVER_ADDR', '');
        }

        // Remove the port number
        $host = strtolower(preg_replace("/:\d+$/", '', trim($host)));

        // Check for forbidden characters
        // Credit: Symfony HTTPFoundation
        if (!empty($host) && !empty(preg_replace("/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/", '', $host))) {
            throw new InvalidArgumentException("Invalid host \"$host\"");
        }

        return $host;
    }
686854
protected function GetConnectionString()
	{
		$cstring = new DBConnectionString();
		$cstring->Host = RequestUtil::Get('host');
		$cstring->Port = RequestUtil::Get('port');
		$cstring->Username = RequestUtil::Get('username');
		$cstring->Password = RequestUtil::Get('password');
		$cstring->DBName = RequestUtil::Get('schema');
		$cstring->Type = RequestUtil::Get('type','MySQL');
		return $cstring;
	}
742214
public function getInfoString() : string
   {

      $out = '';
      $haveData = false;

      if ( isset( $this->_attributes[ 'host' ] ) )
      {
         $out = 'host="' . $this->_attributes[ 'host' ] . '"';
         $haveData = true;
      }
      if ( isset( $this->_attributes[ 'port' ] ) )
      {
         $out .= ( $haveData ? '; ' : '' ) . 'port=' . $this->_attributes[ 'port' ];
         $haveData = true;
      }
      if ( isset( $this->_attributes[ 'dbname' ] ) )
      {
         $out .= ( $haveData ? '; ' : '' ) . 'dbname="' . $this->_attributes[ 'dbname' ] . '"';
         $haveData = true;
      }
      if ( isset( $this->_attributes[ 'unix_socket' ] ) )
      {
         $out .= ( $haveData ? '; ' : '' ) . 'unix_socket="' . $this->_attributes[ 'unix_socket' ] . '"';
         $haveData = true;
      }
      if ( isset( $this->_attributes[ 'charset' ] ) )
      {
         $out .= ( $haveData ? '; ' : '' ) . 'charset="' . $this->_attributes[ 'charset' ] . '"';
         $haveData = true;
      }
      $out .= ( $haveData ? '; ' : '' ) . 'user=[' .
              ( empty( $this->_attributes[ 'user' ] ) ? 'un' : '' ) . 'defined]"';
      $out .= ( $haveData ? '; ' : '' ) . 'password=[' .
              ( empty( $this->_attributes[ 'password' ] ) ? 'un' : '' ) . 'defined]"';

      return $out;

   }
218854
public function HostAndPort() {
      $Host = $this->Host();
      $Port = $this->Port();
      if (!in_array($Port, array(80, 443)))
         return $Host.':'.$Port;
      else
         return $Host;
   }
805108
public function getUrl()
    {
        $proto = $this->getUrlProto();
        $host = $this->getUrlHost();
        $port = $this->getUrlPort($proto);
        

        $url = $proto . '://' . $host;
        if (($proto == 'https' && $port != 443) || ($proto == 'http' && $port != 80)) {
            $url .= ':' . $port;
        }

        if (isset($_SERVER)) {
            $path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
            $url .= $path;
        }

        if ($host == 'unknown') {
            $url = null;
        }

        return $url;
    }