What is the function of $_SERVER['REMOTE_ADDR'] in PHP and how can it be used to retrieve a client's IP address?

$_SERVER['REMOTE_ADDR'] is a PHP superglobal variable that contains the IP address of the client making the request to the server. It can be used to retrieve the client's IP address for various purposes, such as tracking or logging.

// Get the client's IP address using $_SERVER['REMOTE_ADDR']
$client_ip = $_SERVER['REMOTE_ADDR'];

// Output the client's IP address
echo "Client's IP Address: " . $client_ip;