/**

  • 取得IP
  • @return string 字符串类型的返回结果
    */
    function getIp(){
    if (@$_SERVER[‘HTTP_CLIENT_IP’] && $_SERVER[‘HTTP_CLIENT_IP’]!=’unknown’) {
    $ip = $_SERVER[‘HTTP_CLIENT_IP’];
    } elseif (@$_SERVER[‘HTTP_X_FORWARDED_FOR’] && $_SERVER[‘HTTP_X_FORWARDED_FOR’]!=’unknown’) {
    $ip = $_SERVER[‘HTTP_X_FORWARDED_FOR’];
    } else {
    $ip = $_SERVER[‘REMOTE_ADDR’];
    }
    return preg_match(‘/^\d[\d.]+\d$/‘, $ip) ? $ip : ‘’;
    }
     
× 请我吃糖~
打赏二维码