A simple way to obtain the visitor's IP address, with PHP
In some circumstances , it is useful to know the visitor's IP address. There are many ways to do this, the following code presented below is a very simple but effective way.
<?php
$name = "User";
$ip = $_SERVER['REMOTE_ADDR']?:($_SERVER['HTTP_X_FORWARDED_FOR']?:$_SERVER['HTTP_CLIENT_IP']);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Your IP Address</title>
</head>
<body>
<div id="container" style="text-align: center;">
<?php echo "Hello " . $name; ?>
<br />
<?php echo "Your IP Address is: " . $ip; ?>
</div>
</body>
</html>