来源: https://destoon.cc/ 时间: 2019-03-01 22:16:34 人气: 911 评论: 0
在需要的地方把下面一行复制过去就行,
号码归属地:{tel_location($mobile)}
然后把下面一段代码复制到/include/module.func.php文件中?>前面即可:
function tel_location($ip) {
$u = “http://www.youdao.com/smartresult-xml/search.s?type=mobile&q=$ip”;
$r = HttpRequest($u);
preg_match(“#<location>(.+)</location>#Ui”, $r, $m);
return iconv(“GBK”, “UTF-8//IGNORE”, strval($m[1]));
//echo strval($m[1]);
}function HttpRequest($url) {
if ( !function_exists(‘curl_init’) ) { return “<location>暂未能查询到</location>”; }
$timeout = 2;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
$result = curl_exec($ch);
return $result;
}
演示效果如下:
seline; text-decoration: none; color: rgb(0, 153, 204); transition: background 0.2s ease-in-out;">