IP address location in thinkphp, including IP address library file
a few days ago, the study of the TP in the IP address location, really cost some time, now solved, share to everyone.
IP Address Library A bit large, go here to downloadhttp://download.csdn.net/detail/man_quan/4636418
for IP address positioning, the extracted class library file is placed in the thinkphp/extend/library/org/net (if it does not exist manually created) directory below
then use the Import method to introduce post-operation
- import ( ' ORG.Net.IpLocation ' //Import iplocation class
- $Ip = new Iplocation ( ' UTFWry.dat ' //Instantiate class parameter represents IP address library file
- $area = $Ip -> getlocation ( ' 203.34.5.66 ' //gets the location of an IP address
if the passed-in parameter is empty, the current client IP address is automatically obtained, and the location must be properly output, with the UTF8 encoded IP address library file, or the encoding conversion may be required. The IP address library file and the Iplocation class library are located in the same directory.