php读取纯真ip数据库使用示例(2)

case 2: //国家信息被重定向
    fseek($this->fh, $this->getLong3());
    $location['country'] = $this->getInfo();
    fseek($this->fh, $offset + 8);
    $location['area'] = $this->getArea();
    break;

default: //国家信息没有被重定向
    $location['country'] = $this->getInfo($byte);
    $location['area'] = $this->getArea();
    break;
  }

//gb2312 to utf-8(去除无信息时显示的CZ88.NET)
  foreach ($location as $k => $v) {
   $location[$k] = str_replace('CZ88.NET','',iconv('gb2312', 'utf-8', $v));
  }

return $location;
 }

//析构函数
 function __destruct() {
  fclose($this->fh);
 }
}

$ip = new ip();
$addr = $ip -> ip2addr('IP地址');
print_r($addr);
?>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/dbc82df29730513e5b7a0fe08f6e11bc.html