Hướng dẫn php detect country - php phát hiện quốc gia
Xác định quốc gia truy cập vào website thông qua IP - detect country visit website by IP Địa chỉ IP truy vấn đến trang web của bạn có thể lưu trong biến $_SERVER['REMOTE_ADDR']. Bạn có thể tạo truy vấn thử nghiệm bằng cách thay đổi đối số IP vào URL sau: http://api.hostip.info/country.php?ip=$IP Kết quả trả về sẽ là mã quốc gia gồm 2 ký tự của điểm truy cập có IP trên. Dưới đây là code PHP demo cho việc sử dụng API của hostip:
Ngoài AIP trên, bạn có thể lấy hình flag của IP, thông tin miền truy cập của IP vv... xem hướng dẫn sử dụng tại http://www.hostip.info/use.html Ngoài hostip, bạn cũng có thể sử dụng api của trang http://nl.ae/iptocapi.php?type=1&ip=$IP để lấy thông tin như trên. I have written a class based on "Chandra Nakka" answer. Hopefully it can help people out it saves the information from geoplugin to a session so the load is much faster when recalling the information. It also saves the values to a private array so recalling in the same code is the fastest as it could be.
Answering the 'op' question with this class you can call
And the other properties available are:
Returning |