申明:本人通过网上搜索得来,具体出处未知。

代码须联网使用的,使用腾迅的一个api,即http://fw.qq.com/ipaddress
然后用php进行了简单的处理,使返回的结果用数组形式显示:
即Array ( [0] =>110.125.172.210 [1] => [2] => 福建省 [3] => 厦门市)


获取代码如下:
 

<?php
function get_ip_place() {
    $ip = file_get_contents("http://fw.qq.com/ipaddress");
    $ip = str_replace('"', ' ', $ip);
    $ip2 = explode("(", $ip);
    $a = substr($ip2[1], 0, -2);
    $b = explode(",", $a);
    $adress=$b[2].$b[3];
    return $adress;
}

$ip = get_ip_place();
echo $ip."的朋友";
?>


各位可以据此作自行修改。