Voodoo\Core\Http\Request::getIp PHP Method

getIp() public static method

Return the request ip
public static getIp ( ) : string
return string
    public static function getIp()
    {
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } else {
            if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
            } else {
                $ip = $_SERVER['REMOTE_ADDR'];
            }
        }
        return $ip;
    }

Usage Example

示例#1
0
 /**
  * Return the user agent ip
  * @return string
  */
 public function getIp()
 {
     return Http\Request::getIp();
 }