Maybe you want to let all your website visitors to see their IP address, or maybe you want to track visitors to your site. Maybe you have a dynamic IP and want an easy way to figure it out. Well, here’s a super easy script to figure it out. All you need is a webserver and PHP installed.
The command that does all the work is this: $_SERVER[“REMOTE_ADDR”]. If all you want to do is display the IP add this in your line of code:
<?php echo $_SERVER["REMOTE_ADDR"]; ?>
To make it all pretty, here’s what I did:
<center> <h2><u>Your IP Address:</u></h2> <table cellspacing=10 cellpadding=20 border=1><tr><td> <b><?php echo $_SERVER["REMOTE_ADDR"] ?></b> </td></tr></table></center>
To see a working model or use for future reference, go here.
Reference: You can find more information about the $_SERVER variable from the PHP website.