How can the $_SERVER['REMOTE_ADDR'] variable be used to determine a visitor's IP address in PHP?

To determine a visitor's IP address in PHP, you can use the $_SERVER['REMOTE_ADDR'] variable. This variable contains the IP address of the user making the request to the server. By accessing this variable, you can retrieve the IP address and use it for various purposes such as tracking, logging, or geolocation.

// Get the visitor's IP address using $_SERVER['REMOTE_ADDR']
$visitor_ip = $_SERVER['REMOTE_ADDR'];

// Output the IP address
echo "Visitor's IP Address: " . $visitor_ip;