Are there any potential privacy concerns when using PHP to access and display visitor IP data?

When using PHP to access and display visitor IP data, there is a potential privacy concern as IP addresses can be considered personally identifiable information. To address this concern, it is recommended to anonymize the IP address before displaying it to ensure the privacy of visitors.

// Get visitor IP address
$visitor_ip = $_SERVER['REMOTE_ADDR'];

// Anonymize IP address
$anonymized_ip = preg_replace('/\d+$/', '0', $visitor_ip);

// Display anonymized IP address
echo "Visitor IP: " . $anonymized_ip;