Request::getPort PHP Method

getPort() public static method

This method can read the client port from the "X-Forwarded-Port" header when trusted proxies were set via "setTrustedProxies()". The "X-Forwarded-Port" header must contain the client port. If your reverse proxy uses a different header name than "X-Forwarded-Port", configure it via "setTrustedHeaderName()" with the "client-port" key.
public static getPort ( ) : string
return string
        public static function getPort()
        {
            //Method inherited from \Symfony\Component\HttpFoundation\Request
            return \Illuminate\Http\Request::getPort();
        }

Usage Example

Example #1
0
function websocket_url($path = '', $port = false, $tail = '', $scheme = 'ws://')
{
    $root = Request::getHost();
    $start = starts_with($root, 'http://') ? 'http://' : 'https://';
    $root = $scheme . $root;
    $root .= ':' . ($port ? $port : Request::getPort());
    return trim($root . ($path ? '/' . trim($path . '/' . $tail, '/') : ''), '/');
}
All Usage Examples Of Request::getPort