What are some ways to retrieve the WAN-IP address of a server behind a router using PHP?

To retrieve the WAN-IP address of a server behind a router using PHP, you can make a request to an external service that returns the IP address of the client making the request. One common method is to use an API service like ipify.org. You can make a simple HTTP request to their API endpoint and parse the response to get the WAN-IP address.

$ip = file_get_contents('https://api.ipify.org');
echo "WAN-IP Address: " . $ip;