You are here

public static function SmartIp::ipAddressVersion in Smart IP 8.3

Same name and namespace in other branches
  1. 8.4 src/SmartIp.php \Drupal\smart_ip\SmartIp::ipAddressVersion()

Determine IP address version.

Parameters

string $ipAddress: IP address to check for version.

Return value

int

File

src/SmartIp.php, line 431
Contains \Drupal\smart_ip\SmartIp.

Class

SmartIp
Smart IP static basic methods wrapper.

Namespace

Drupal\smart_ip

Code

public static function ipAddressVersion($ipAddress = NULL) {
  if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
    return 4;
  }
  elseif (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
    return 6;
  }
}