Devanshu Sharma
Devanshu Sharma

Reputation: 23

How to Get 2 Digit Country Code by Using php

Hello Friends I was Developing an website which i only want to be viewed by Indian (People of india) , and I Want to Get The Two Digit Country Code for that using php. I browsed to http://php.net and tried using geoip_country_code_by_name , geoip_country_code3_by_name and geoip_country_name_by_name but None of Function worked , I have tried on my Existing XAMPP Installation and W3schools PHP runner but it says function not exists and i also have checked to PHP version. What Should i Do. I also Have tried methods form here and after Google(ing) whole day i finally came to ask here .


Feel Free to Suggest Edit or Close this Question

Upvotes: 1

Views: 402

Answers (1)

Patfreeze
Patfreeze

Reputation: 720

Based on some research, the best way seems to be by IP. This link will help you if you go this way. https://stackoverflow.com/a/13600004/13604954

But some VPN can easily change is on IP. ref. https://nordvpn.com/blog/vpn-ip-location-changer/

So good luck! 😉

The easiest way will be to asking the user is country and if not what you want, just show another page.

Upvotes: 1

Related Questions