In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to query users'ip with php". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to query users'ip with php".
Php query user ip method: 1, through "$_ SERVER [" REMOTE_ADDR "]" way to get user ip;2, through "($user_IP)? $user_IP: $_ SERVER [" REMOTE_ADDR "];" get user ip, and so on.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
How does php query a user's ip?
Five ways for php to obtain user ip
/ / how to get user ip 1$ ip= $_ SERVER ["REMOTE_ADDR"]; how echo $ip;// gets user ip 2 $user_IP = ($_ SERVER ["HTTP_VIA"])? $_ SERVER ["HTTP_X_FORWARDED_FOR"]: $_ SERVER ["REMOTE_ADDR"]; $user_IP = ($user_IP)? $user_IP: $_ SERVER ["REMOTE_ADDR"]; echo $user_IP;// how to get user ip 3function getRealIp () {$ip=false If (! empty ($_ SERVER ["HTTP_CLIENT_IP"]) {$ip = $_ SERVER ["HTTP_CLIENT_IP"];} if (! empty ($_ SERVER ['HTTP_X_FORWARDED_FOR'])) {$ips = explode (",", $_ SERVER [' HTTP_X_FORWARDED_FOR']); if ($ip) {array_unshift ($ips, $ip); $ip = FALSE;} for ($I = 0; $I < count ($ips) ) {if (! eregi ("^ (10 │ 172.16 │ 192.168), $ips [$I])) {$ip = $ips [$I]; break;} return ($ip? $ip: $_ SERVER ['REMOTE_ADDR']);} echo getRealIp (); / / how to obtain user ip 4if ($HTTP_SERVER_VARS [" HTTP_X_FORWARDED_FOR "]) {$ip = $HTTP_SERVER_VARS [" HTTP_X_FORWARDED_FOR "] } elseif ($HTTP_SERVER_VARS ["HTTP_CLIENT_IP"]) {$ip = $HTTP_SERVER_VARS ["HTTP_CLIENT_IP"];} elseif ($HTTP_SERVER_VARS ["REMOTE_ADDR"]) {$ip = $HTTP_SERVER_VARS ["REMOTE_ADDR"];} elseif (getenv ("HTTP_X_FORWARDED_FOR")) {$ip = getenv ("HTTP_X_FORWARDED_FOR");} elseif (getenv ("HTTP_CLIENT_IP")) {$ip = getenv ("HTTP_CLIENT_IP") } elseif (getenv ("REMOTE_ADDR")) {$ip = getenv ("REMOTE_ADDR");} else {$ip = "Unknown";} echo $ip; / / how to obtain user ip 5if (getenv ('HTTP_CLIENT_IP')) {$onlineip = getenv (' HTTP_CLIENT_IP');} elseif (getenv ('HTTP_X_FORWARDED_FOR')) {$onlineip = getenv (' HTTP_X_FORWARDED_FOR') } elseif (getenv ('REMOTE_ADDR')) {$onlineip = getenv (' REMOTE_ADDR');} else {$onlineip = $HTTP_SERVER_VARS ['REMOTE_ADDR'];} echo $onlineip; here, I believe you have a deeper understanding of "how to query users' ip with php". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.