getRemote() публичный статический Метод

Returns the IP address of the client.
public static getRemote ( boolean $trustProxy = false ) : string
$trustProxy boolean Whether or not to trust the proxy headers HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR. ONLY use if your server is behind a proxy that sets these values
Результат string
Пример #1
0
 public function testGetRemote()
 {
     $_SERVER['REMOTE_ADDR'] = '192.168.0.1';
     $_SERVER['HTTP_CLIENT_IP'] = '192.168.0.2';
     $_SERVER['HTTP_X_REAL_IP'] = '192.168.0.3';
     $_SERVER['HTTP_X_FORWARDED_FOR'] = '192.168.0.4';
     is('192.168.0.1', Sys::IP());
     // Check deprecated method
     is('192.168.0.1', IP::getRemote());
     is('192.168.0.2', IP::getRemote(true));
     unset($_SERVER['HTTP_CLIENT_IP']);
     is('192.168.0.3', IP::getRemote(true));
     unset($_SERVER['HTTP_X_REAL_IP']);
     is('192.168.0.4', IP::getRemote(true));
     unset($_SERVER['HTTP_X_FORWARDED_FOR']);
     is('192.168.0.1', IP::getRemote(true));
 }