当前位置:编程学习 > php >>

求这段简单的php代码(腾讯api获取用户所在城市)应该怎么使用?

代码如下:比如我想在一个html页面里显示“欢迎您,来自...的朋友”。应该怎么用? < ?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); return $b; } $ip=get_ip_place(); print_r($ip[3]); //这个就是你需要的城市了 ?>
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,