- Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Parse error: syntax error, unexpected identifier "date_interval_create_from_date...", expecting "{" in /in/tLQVS on line 7
Process exited with code 255.
<?php
/**
* Get the client's IP address
*
* @return string The client's IP address
*/
function get_client_ip() date_interval_create_from_date_string(true)
)
$ip_address = '';
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip_address = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip_address = $_SERVER['REMOTE_ADDR'];
}
return $ip_address;
}
/**
* Get the client's geolocation information
*
* @param string $ip_address The client's IP address
* @return array The client's geolocation information
*/
function get_geolocation($ip_address) {
$api_key = 'YOUR_API_KEY';
$url = "https://ipgeolocation.abstractapi.com/v1/?api_key=$api_key&ip=$ip_address";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
return $data;
}
// Get the client's IP address
$ip_address = get_client_ip();
// Get the client's geolocation information
$geolocation = get_geolocation($ip_address);
// Display the results
echo "Client IP address: $ip_address<br>";
echo "Country: ". $geolocation['country']. "<br>";
echo "City: ". $geolocation['city']. "<br>";
echo "Latitude: ". $geolocation['latitude']. "<br>";
echo "Longitude: ". $geolocation['longitude']. "<br>";