IP address location in ThinkPHP, including IP address Library Information

Source: Internet
Author: User
IP address location in ThinkPHP, including IP address location in the IP address library file a few days ago, I studied IP address location in TP. it took some time to solve the problem and I will share it with you. The IP address Library is a bit large. download. csdn. netdetailman_quan4636418 here for IP address locating. the decompressed class library file is placed into the IP address location in ThinkPHPExtendLibraryORG ThinkPHP, including the IP address library file

A few days ago, I studied IP address location in TP, which took some time. now I have solved the problem and I will share it with you.
The IP address Library is a bit big, go here to download http://download.csdn.net/detail/man_quan/4636418
Used for IP address locating. the decompressed class Library file is placed in the ThinkPHP/Extend/Library/ORG/Net directory (if not, manually create it ).
Then, use the import method to import and then perform the operation.

  1. Import ('org. Net. iplocation'); // import the IpLocation class
  2. $ Ip = newIpLocation ('utfwry. dat '); // The instancetype parameter indicates the Ip address library file.
  3. $ Area = $ Ip-> getlocation ('192. 34.5.66 '); // Obtain the location of an Ip address
If the input parameter is null, the current client IP address is automatically obtained. to output the correct location, you must use the IP address library file encoded with UTF8; otherwise, you may need to perform encoding conversion. The IP address library file and the IpLocation class library are in the same directory.


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.