What is the difference between LAN IPs and WAN IPs in PHP and how can they be accessed?

LAN IPs are used within a local network to identify devices, while WAN IPs are used to identify devices on the internet. In PHP, you can access the LAN IP of a device using the $_SERVER['SERVER_ADDR'] variable, which will return the local IP address of the server. To access the WAN IP, you can use external services like 'https://api.ipify.org'.

// Get LAN IP address
$lan_ip = $_SERVER['SERVER_ADDR'];
echo "LAN IP Address: " . $lan_ip;

// Get WAN IP address
$wan_ip = file_get_contents('https://api.ipify.org');
echo "WAN IP Address: " . $wan_ip;