【问题标题】:File_get_contents function does not work with windows? [closed]File_get_contents 函数不适用于 windows? [关闭]
【发布时间】:2013-07-13 17:21:57
【问题描述】:
file_get_contents("https://api.groupon.com/v2/deals.xml?division_id=cleveland&client_id=39ddf70c45844d5a9d5a92e5106f1b229b2e1df8");

此代码不适用于 Windows,但适用于 Linux。因为https。有什么解决办法吗?

【问题讨论】:

  • “它不起作用”,不是错误。相反,告诉我们你得到了什么?错误?白页...
  • 显示白页。
  • 另一个链接怎么样?喜欢StackOverflow ?
  • 如果 URL 是 http,文件获取内容将起作用。如果是 https,则文件获取内容将不起作用。(仅在 windows 上)
  • 您应该确保 https 是使用phpinfo 注册的流。

标签: php linux windows file-get-contents groupon


【解决方案1】:

可能你没有在你的 PHP 配置中打开你的 url 文件。

有关此配置值的详细信息,请参阅http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

如果这不是原因,那么您应该指定确切的错误是什么,通过将以下内容添加到您的代码中,在 file_get_contents 函数之前:

error_reporting(E_ALL);
ini_set('display_errors', 'On');

【讨论】:

  • 这些是在解析 "file_get_contents() [function.file-get-contents] 时显示的错误:无法找到包装器 "https" - 您在配置 PHP 时是否忘记启用它?消息:file_get_contents(api.groupon.com/v2/…) [function.file-get-contents]:无法打开流:没有这样的文件或目录“
猜你喜欢
  • 2014-10-08
  • 2011-06-22
  • 1970-01-01
  • 1970-01-01
  • 2013-12-28
  • 2020-04-22
  • 1970-01-01
  • 1970-01-01
  • 2012-10-19
相关资源
最近更新 更多