What are the security implications of using PHP to access and display WAN-IP address information on a website?

Exposing WAN-IP address information on a website using PHP can pose security risks as it may reveal sensitive network information to potential attackers. To mitigate this risk, it is important to sanitize user input and validate the source of the IP address data to prevent injection attacks. Additionally, consider limiting access to this information to authenticated users only.

// Sample PHP code to securely access and display WAN-IP address information
$wan_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
echo "Your WAN-IP address is: " . $wan_ip;