【问题标题】:in php, use curl or file_get_content to get current location through url在 php 中,使用 curl 或 file_get_content 通过 url 获取当前位置
【发布时间】:2013-02-13 13:24:49
【问题描述】:

此链接返回我当前的位置: https://j.maxmind.com/app/country.js 是新加坡。 但是,如果我在 php 文件中使用 file_get_contents('https://j.maxmind.com/app/country.js'),它会返回美国。为什么?

【问题讨论】:

  • 因为托管您调用file_get_contents 的PHP 文件的服务器位于美国。不客气。

标签: php curl file-get-contents geoip


【解决方案1】:

因为它是在服务器端执行的。您的网站托管在美国服务器上。因此,如果您通过服务器端语言调用函数,它不会从用户执行,而是从服务器执行并使用服务器位置。

【讨论】:

    【解决方案2】:

    很简单。 JavaScript 在本地运行 当您打开 https://j.maxmind.com/app/country.js 时,它会在您的计算机中运行,而当您使用 file_get_contents('https://j.maxmind.com/app/country.js') 时,它会在您的服务器中运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-01
      • 2014-11-13
      • 2016-12-17
      • 1970-01-01
      • 2018-03-16
      • 1970-01-01
      • 1970-01-01
      • 2016-08-06
      相关资源
      最近更新 更多