Home >Backend Development >PHP Tutorial >Get the client's IP address
There are two ways to get the client’s IP address, getenv(“REMOTE_ADDR”) and $_SERVER[‘REMOTE_ADDR’]
If the server space is IIS, use $_SERVER[‘REMOTE_ADDR’]
If the server space is apache, use getenv("REMOTE_ADDR")
Summary:
getenv("REMOTE_ADDR") function can obtain the IP address normally under apache, but in iis, it has no effect at all, and $_SERVER['REMOTE_ADDR '] function can successfully obtain the visitor's IP address in Apache and is also effective under IIS.
The above introduces how to obtain the client's IP address, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.