function get_client_city(){ $ip=getip(); if($ip){ $response = HTTP::request("https://restapi.amap.com/v3/ip?ip=$ip&output=json&key=高德的开发者KEY", 'GET'); //print_r($response); if ($response) { $response = json_decode($response); if($response->status=="1"){ return $response->city; } } } }
到时候只需要判断返回的数据是 北京市、上海市、苏州市、广州市、杭州市就可以了。