What is the purpose of using $_SERVER['REMOTE_ADDR'] in PHP?

The purpose of using $_SERVER['REMOTE_ADDR'] in PHP is to retrieve the IP address of the client making the request to the server. This can be useful for tracking and logging user activity, implementing security measures, or customizing content based on the user's location.

// Get the IP address of the client
$ip_address = $_SERVER['REMOTE_ADDR'];

// Output the IP address
echo "Your IP address is: " . $ip_address;