php多城市切换
程序员文章站
2022-06-04 14:15:39
...
无详细内容 PHP MyBlog ?php/**///??è?ip/*include_once('./qqwry.php');$QQWry=new QQWry; function get_real_ip(){$ip=false;if(!empty($_SERVER["HTTP_CLIENT_IP"])){$ip = $_SERVER["HTTP_CLIENT_IP"];}if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
PHP MyBlog
4) return 0; foreach($ip as $ip_addr) { if ( !is_numeric($ip_addr) ) return 0; if ( $ip_addr255 ) return 0; } return 1; } $ip=$_SERVER['REMOTE_ADDR']; $ifErr=$QQWry->QQWry($ip); $city = $QQWry->Country.$QQWry->Local; //echo $city;*/ if (strpos($city,'玄武区')!==false){ $city = "玄武区"; } else if(strpos($city,'仙林')!==false){ $city = "仙林"; } else if(strpos($city,'秦淮区')!==false){ $city = "秦淮区"; } else if(strpos($city,'江宁')!==false){ $city = "江宁"; } else if(strpos($city,'鼓楼')!==false){ $city = "鼓楼"; } else{ $city = "栖霞"; } if (isset($_GET['chengshi'])) { //ê×?è?ì2aê?·???μ?á? GET ′?μYμ?êy?Y setcookie("cookie_city",$_GET['chengshi'],time()+3600*24); $city = $_GET['chengshi']; } else if (isset($_COOKIE["cookie_city"])) { //?ì2aê?·?′??úê?3?Cookie $city = $_COOKIE["cookie_city"]; //??ê?Cookie±£′?μ?êy?Y } else { setcookie("cookie_city",$city,time()+3600*24); //′?3?ê??ˉ′?±?á? $_COOKIE["cookie_city"] = $city; } ?>城市切换
- 全部小区
- 切换城市
上一篇: 优化PHP程序的步骤
下一篇: 知乎上有哪些 PHP 牛人?