<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                今天分享一個PHP根據客戶端IP地址獲得所屬地的小程序,以前寫的,已經用了很久了,感覺這個接口還是停穩定的。雖然現在網上也有很多類似的,但是我覺得我這個還是很不錯的,核心代碼只用3行就能實現。雖然功能不是很強大,但是我們平時算是夠用的。以下是代碼: ~~~ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>通過IP獲取歸屬地</title> </head> <body> <form action="" method="post"> <p>請輸入ip地址:<input type="text" name="ip" /></p> <p><input type="submit" value="查詢" /></p> </form> <?php //獲取ip地址 //$ip = $_SERVER['REMOTE_ADDR']; //自動獲取客戶端的IP //ip對應的地區 if(!empty($_POST['ip'])){ $ip = $_POST['ip']; //接口地址,這樣返回的是一個xml結果集,如圖1; $str = file_get_contents("http://www.yodao.com/smartresult-xml/search.s?type=ip&q=".$ip); //這里要得到里面的地址信息,提取xml方法有很多,我用的是正則。 preg_match_all( "/\<location\>(.*?)\<\/location\>/",$str,$addr1); //最終結果,如圖2; $addr = $ip."=>".$addr1[1][0]; echo $addr; } ?> </body> </html> ~~~ 如果喜歡的話,可以試試,幾行代碼就能搞定,我覺得還是挺實用的!!
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看