Which php global contains the user IP Address?

Question:

Which php global contains the IP address of the user/client calling the script?

Answer:

$_SERVER['REMOTE_ADDR'];

Note that this does not take into account any proxy which might be in use. There are numerous issues to take into account if you wan to to be absolutely sure of the remote IP. This example is for the simplest cases.

$user_ip = $_SERVER['REMOTE_ADDR'];

echo "

your IP is $user_ipn";

Leave a Reply

Your email address will not be published. Required fields are marked *