PHP IP address and other details

How can I get the IP address and other details of a user to my site?
Answer:
One can use SERVER var $_SERVER['SERVER_ADDR'] and getenv("REMOTE_ADDR") functions to get the IP address of any visitor to your site.

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server depending on the user who is visiting your website or using your script.

Example:
$ipaddress =_SERVER['SERVER_ADDR'];

0 comments:

Post a Comment