What are the benefits of using $_SERVER over deprecated HTTP_-Globals in PHP code?

The issue with using deprecated HTTP_-Globals in PHP code is that they are not secure and can be easily manipulated by users. It is recommended to use the $_SERVER superglobal instead, as it provides a more secure way to access server variables.

// Using $_SERVER superglobal instead of deprecated HTTP_-Globals
$ipAddress = $_SERVER['REMOTE_ADDR'];
$userAgent = $_SERVER['HTTP_USER_AGENT'];

echo "IP Address: " . $ipAddress . "<br>";
echo "User Agent: " . $userAgent;