28
clientipaddress
client_ip_address
SYNOPSIS
client_ip_address()
DESCRIPTION
client_ip_address
returns the IP address of the system which has sent the HTTP request.
If PHP is in SAPI CLI, client_ip_address
returns the local address 127.0.0.1
.
CODE
- function client_ip_address() {
- return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : (php_sapi_name() == 'cli' ? '127.0.0.1' : false); // DON'T TRUST $_SERVER['HTTP_X_FORWARDED_FOR']
- }
Comments