IP() public static method

Get remote IP
Deprecation: use IP::getRemote()
public static IP ( boolean $trustProxy = false ) : string
$trustProxy boolean
return string
Esempio n. 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));
 }