Php code for Obtaining geographic locations through IP address (thieves program) _ PHP Tutorial

Source: Internet
Author: User
Php code for Obtaining geographic locations through IP addresses (thieves program ). The copy code is as follows: functionget_ip_place () {$ ipfile_get_contents (fw. qq. comipaddress); $ ipstr_replace (, $ ip); $ ip2explode (, $ ip); $ asubstr ($ ip2 [1], 0 ,- The code is as follows:


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 (",", $ );
Return $ B;
}


I am sorry for all the news from the true XXX written in open-source China. We use regular expressions to write more easily.

Let's see.

The code is as follows:


Function get_ip_arr ()
{
$ Ip = file_get_contents ("http://fw.qq.com/ipaddress ");
Preg_match_all ("/\" (. *) \ "/", $ ip, $ arr );
Return $ arr;
}


The returned result is an array, which can be any region or ip address.

Of course, you can also read IP addresses through php. the advantage of this code is resource saving.

The http://www.bkjia.com/PHPjc/323584.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/323584.htmlTechArticle code is as follows: 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 ,-...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.