简体   繁体   中英

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.

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.

$_SERVER['REMOTE_ADDR']$_SERVER['REMOTE_HOST']查找使用PHP获取客户端IP地址

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM