IP() 공개 정적인 메소드

Get remote IP
사용 중단: use IP::getRemote()
public static IP ( boolean $trustProxy = false ) : string
$trustProxy boolean
리턴 string
예제 #1
0
파일: IpTest.php 프로젝트: jbzoo/utils
 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));
 }