6

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
  1. function client_ip_address() {
  2.     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']
  3. }
SEE ALSO

serveripaddress, validateipaddress

Comments

To add a comment, click here.