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 http://download.csdn.net/detail/man_quan/4636418for IP address location in 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.
- Import ('org. Net. iplocation'); // import the IpLocation class
- $ Ip = newIpLocation ('utfwry. dat '); // The instancetype parameter indicates the Ip address library file.
- $ 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.