一、显示访问用户的IP地址及地理位置
<script type="text/javascript" src="http://fw.qq.com/ipaddress"></script>
<script type="text/javascript">
document.write(IPData.join(''));
</script>

效果:
xxx.xxx.xxx.xxx 某某省 某某市

二、自定义显示IP、省、市
<script type="text/javascript" src="http://fw.qq.com/ipaddress"></script>
<script type="text/javascript">
document.write(IPData[0]);    //显示IP地址
document.write(IPData[2]);    //显示省
document.write(IPData[3]);    //显示市
</script>

三 php版本

function getIpPlace(){
$ip2=file_get_contents("http://fw.qq.com/ipaddress");
$ip2=str_replace('"',' ',$ip2);
$ip3=explode("(",$ip2);
$a=substr($ip3[1],0,-2);
$b=explode(",",$a);
return $b;
}
$ip2=getIpPlace();
$city=trim($ip2[2]).trim($ip2[3]); //0返回IP,2返回省,3返回市

从上面最后一行的注释的地方可以看到$ip2[0] 0为显示的IP,$ip2[2] 0为显示的省名,$ip2[3] 0为显示的市名,默认我没有加显示IP。