This article mainly introduces the use of PHP to obtain the user client real IP method, has a certain reference value, now share to everyone, have the need for friends can refer to
Getting the client IP is not a simple job, because there are IP
In this paper, we describe the encapsulation class of PHP for client and server IP. Share to everyone for your reference, as follows:
Client IP-related variables:
1. $_server[' REMOTE_ADDR '; Client IP, which may be the IP of the user or the IP of
The external java/php server-side acquisition client IP is the same: pseudo-code:1) IP = Request.getheader ("x-forwarded-for") can be forged, refer to Appendix A 2) If the value is empty or the array length is 0 or equal to "unknown", then:IP =
Getting the client IP is not a simple job, because there are IP spoofing, and proxy problems, so the authenticity of the IP to obtain the client will be discounted, can not be hundred accurate. But we still try to find a better way to get the real
$_server["REMOTE_ADDR" is often used in PHP to obtain client IP.(1) But if the client is using a proxy server for access, then the IP address of the proxy server is taken, not the real client IP address. To obtain the client's true IP address
Getting the client IP is not really a simple job, because there are IP spoofing, and agent issues, so get the authenticity of the client's IP will be discounted, not hundred percent accurate. But we still try to find a better way to get the client
Php function to obtain the online ip address and client ip address
/**
* Obtain the client ip address
* @ Return [string] [description]
*/
Function getclientip (){
$ Ip = null;
If
Limit the IP voting program, can not use the web search for PHP to obtain the client IP code to obtain the client IP-reproduced
the need to get a polling campaign needs to be done IP restrictions, each IP limit a certain chance of voting. I
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.