public static function getClientIp(): ?string
    {
        $ip = null;
        if (null != ($ip = self::getEnv('HTTP_X_FORWARDED_FOR'))) {
            if (false !== strpos($ip, ',')) {
                $ip = trim((string) end(explode(',', $ip)));
            }
        }
        // all ok
        elseif (null != ($ip = self::getEnv('HTTP_CLIENT_IP'))) {}
        elseif (null != ($ip = self::getEnv('HTTP_X_REAL_IP'))) {}
        elseif (null != ($ip = self::getEnv('REMOTE_ADDR_REAL'))) {}
        elseif (null != ($ip = self::getEnv('REMOTE_ADDR'))) {}

        return $ip;
    }
public static function getClientIp(): ?string
    {
        $ip = null;
        if (null != ($ip = self::getEnv('HTTP_X_FORWARDED_FOR'))) {
            if (false !== strpos($ip, ',')) {
                $ip = trim((string) end(explode(',', $ip)));
            }
        }
        // all ok
        elseif (null != ($ip = self::getEnv('HTTP_CLIENT_IP'))) {}
        elseif (null != ($ip = self::getEnv('HTTP_X_REAL_IP'))) {}
        elseif (null != ($ip = self::getEnv('REMOTE_ADDR_REAL'))) {}
        elseif (null != ($ip = self::getEnv('REMOTE_ADDR'))) {}

        return $ip;
    }
public static function getClientIp ( ) : ? string { $ ip = null ; if ( null != ( $ ip = self :: getEnv ( 'HTTP_X_FORWARDED_FOR' ) ) ) { if ( false !== strpos ( $ ip , ',' ) ) { $ ip = trim ( ( string ) end ( explode ( ',' , $ ip ) ) ) ; } } // all ok elseif ( null != ( $ ip = self :: getEnv ( 'HTTP_CLIENT_IP' ) ) ) { } elseif ( null != ( $ ip = self :: getEnv ( 'HTTP_X_REAL_IP' ) ) ) { } elseif ( null != ( $ ip = self :: getEnv ( 'REMOTE_ADDR_REAL' ) ) ) { } elseif ( null != ( $ ip = self :: getEnv ( 'REMOTE_ADDR' ) ) ) { } return $ ip ; }
Get client ip.
@return ?string
Get client ip .