Get real ip address php
I'm using this PHP code to get a visitor's IP address: Show
But, I can't get the real IP address from visitors when they are using a proxy. Is there any way to get a visitor's IP address in this case?
reformed 4,24510 gold badges59 silver badges83 bronze badges asked Nov 30, 2012 at 13:58 4 Try this php code.
Mario 1,2943 gold badges20 silver badges39 bronze badges answered Nov 30, 2012 at 14:01 10 This is the most common technique I've seen:
Note that it does not guarantee it you will get always the correct user IP because there are many ways to hide it.
answered Nov 30, 2012 at 14:08
TeneffTeneff 27.8k9 gold badges64 silver badges96 bronze badges 4 This is my approach:
How to use:
answered Mar 3, 2015 at 23:36
El ceroEl cero 5694 silver badges13 bronze badges 7
Proxies may send a Also keep in mind that visitors may share IP addresses; University networks, large companies and third-world/low-budget ISPs tend to share IPs over many users. answered Nov 30, 2012 at 13:59
HalcyonHalcyon 56.6k10 gold badges87 silver badges126 bronze badges 2 apply this code for get the ipaddress:
Arpit Patel 9,2155 gold badges63 silver badges72 bronze badges answered Feb 22, 2016 at 8:51
This is my function. benefits :
answered May 2, 2017 at 12:47
If the Proxy is which you trust, you can try: (Assume the Proxy IP is
This will prevent forged forward header by direct requested clients, and get real IP via trusted Proxies. answered Jul 8, 2017 at 2:15
Nick TsaiNick Tsai 3,51731 silver badges34 bronze badges Yes, But your best bet is to run answered Nov 30, 2012 at 14:03
NelsonNelson 47.4k8 gold badges64 silver badges79 bronze badges This works for Windows and Linux! It doesn't matter if it's localhost or online..
answered Nov 17, 2015 at 13:45
ValconeValcone 592 silver badges14 bronze badges 5 How can I get a real IP address?Find your IP address using the command prompt (CMD). Open the Start menu and type cmd to open the Command Prompt.. Type ipconfig into the Command Prompt and press Enter. The tool will return a set of data that includes your IP address.. How can I get IP address in PHP?Using getenv() function: To get the IP Address,we use getenv(“REMOTE_ADDR”) command. The getenv() function in PHP is used for retrieval of values of an environment variable in PHP. It is used to return the value of a specific environment variable.
How can I get static IP in PHP?In order to obtain the IP address of the server one can use ['SERVER_ADDR'], it returns the IP address of the server under the current script is executing. Another method is using the ['REMOTE_ADDR'] in the $_SERVER array.
What is $_ server [' Remote_addr ']?$_SERVER['REMOTE_ADDR'] Returns the IP address from where the user is viewing the current page. $_SERVER['REMOTE_HOST'] Returns the Host name from where the user is viewing the current page. $_SERVER['REMOTE_PORT']
|