how to print current user's ip address in php 7.1.1

I am trying to get current users ip address using {$_SERVER['REMOTE_ADDR']} or {getenv('REMOTE_ADDR')}, in both of the cases i am getting ::1 . I am using php 7.1.1, can any one help how i can get current ip address of current user.

Upvotes: 0

Views: 2126

Answers (2)

mohe14
mohe14

Reputation: 47

$_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] look to Get the client IP address using PHP

Upvotes: 0

dsadnick
dsadnick

Reputation: 624

If your using your local server it will always be ::1 or the local ip address.

$_SERVER['REMOTE_ADDR']

will return the ip when its on a server outside of your localnetwork.

Upvotes: 1

Related Questions