Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Request.php

function Request::getClientIps

Returns the client IP addresses.

In the returned array the most trusted IP address is first, and the least trusted one last. The "real" client IP address is the last one, but this is also the least trusted one. Trusted proxies are stripped.

Use this method carefully; you should use getClientIp() instead.

See also

getClientIp()

File

vendor/symfony/http-foundation/Request.php, line 742

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public function getClientIps() : array {
    $ip = $this->server
        ->get('REMOTE_ADDR');
    if (!$this->isFromTrustedProxy()) {
        return [
            $ip,
        ];
    }
    return $this->getTrustedValues(self::HEADER_X_FORWARDED_FOR, $ip) ?: [
        $ip,
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal