search
Homephp教程php手册php获取Chianz.com IP地址与地区方法

一个IP获取的结果不是很完善,究其原因是因为ip138的IP解析应对国外的地址时不是很详细,所以又重新写了个用Chianz.com的代码,实例代码如下:

<!DOCTYPE html>  
	<html lang="en">  
	<head>  
	<title></title>  
	<meta charset="UTF-8" />  
	<meta name="author" content="" />  
	<meta name="keywords" content="" />  
	<meta name="description" content="" />  
	</head> //开源代码phprm.com 
	<body>  
	<?php 
	$ipAddr = "4.4.44.4";  
	$ipChinazAddr = "http://tool.chinaz.com/IP/?IP=".$ipAddr;  
	$contents = file_get_contents($ipChinazAddr);  
	$pattern = "/==>>.+</strong><br />/";  
	$string = $contents;  
	preg_match_all($pattern,$string,$addrArray);  
	$num = count($addrArray[0]);  
	$pattern = "/(==>>).+(==>>s)/";  
	for($i = 0;$i<$num;$i++){  
	$addrArray[0][$i] = preg_replace($pattern,"",$addrArray[0][$i]);  
	}  
	echo "<pre class="brush:php;toolbar:false">";  
	print_r($addrArray);  
	echo "
";     
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use