How can I get user's country flag on my site

前端 未结 5 1900
野性不改
野性不改 2021-02-10 13:04

I wanna display user\'s/visitor\'s country flag on my site.

I am using different technologies like php,jsp and simple html. So I want a code which by placing on my site,

5条回答
  •  没有蜡笔的小新
    2021-02-10 13:35

    You can use the GeoIP extension and then map the country in question to a given icon.

    $countryName = geoip_country_name_by_name($_SERVER['REMOTE_ADDR']);
    echo $countryName;
    

    Note that getting the country via IP is not exact.

提交回复
热议问题