ExpressionEngine® User Guide

IP Address Service

Overview

The IP Address service contains methods for performing actions on IP Addresses. Example call:

$ip_address = ee('IpAddress')->anonymize($ip_address);

IP Address Service Methods

anonymize($address)

Anonymizes an IPv4 or IPv6 IP Address by using a subnet mask of 255.255.255.0 or ffff:ffff:ffff:ffff:0000:0000:0000:0000 respectively. Useful for when you need to remove the specificity of an IP address but still retain general geographic information.

Parameters:
  • $address (string) – IP address that must be anonymized
Returns:

The anonymized IP address. Returns an empty string when the IP address is invalid.

Return type:

string