PHP IF Statment Based On Geo Location?

前端 未结 4 1511
忘掉有多难
忘掉有多难 2021-01-07 01:43

Is there a way to do a PHP If statement based on the persons location?

My problem comes down to Amazon Affiliate links. The link to buy a DVD on Amazon.co.uk is diff

4条回答
  •  清歌不尽
    2021-01-07 02:04

    You can use: string geoip_country_code_by_name ( string $hostname )

    Example:

    
    

    Output:

    This host is located in: US

    For your case you can use: geoip_country_code_by_name($_SERVER['REMOTE_ADDR']); to get the country code for the current user.

提交回复
热议问题