file_get_contents返回空字符串 [英] file_get_contents returns empty string

查看:94
本文介绍了file_get_contents返回空字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想问这个问题,因为它看起来很奇怪. 但不管怎么说. 万一有人已经遇到了同样的问题... 文件系统功能(fopem,file,file_get_contents)对于http://包装器而言非常奇怪

I am hesitated to ask this question because it looks weird. But anyway. Just in case someone had encountered the same problem already... filesystem functions (fopem, file, file_get_contents) behave very strange for http:// wrapper

  • 它似乎有效. 没有错误. fopen()返回资源.
  • 对于所有肯定有效的网址(例如http://google.com/),它不返回任何数据.
    文件返回空数组,file_get_contents()返回空字符串,fread返回false
  • 对于所有故意错误的网址(例如http://goog973jd23le.com/),它的行为完全相同,除了很少的[理应是域查找]超时,此后我没有收到任何错误(虽然应该!),但字符串为空.
  • url_fopen_wrapper已打开
  • curl(命令行和php版本)都可以正常工作,所有其他实用程序和应用程序都可以正常工作,本地文件可以正常打开
  • it seemingly works. no errors raised. fopen() returns resource.
  • it returns no data for all certainly working urls (e.g. http://google.com/).
    file returns empty array, file_get_contents() returns empty string, fread returns false
  • for all intentionally wrong urls (e.g. http://goog973jd23le.com/) it behaves exactly the same, save for little [supposedly domain lookup] timeout, after which I get no error (while should!) but empty string.
  • url_fopen_wrapper is turned on
  • curl (both command line and php versions) works fine, all other utilities and applications works fine, local files opened fine

此错误似乎不适用,因为在我看来,该错误不适用于每个网址或主机.

This error seems inapplicable because in my case it doesn't work for every url or host.

php-fpm 5.2.11 Linux版本2.6.35.6-48.fc14.i686(mockbuild@x86-18.phx2.fedoraproject.org)

php-fpm 5.2.11 Linux version 2.6.35.6-48.fc14.i686 (mockbuild@x86-18.phx2.fedoraproject.org)

推荐答案

我通过从PHP配置中删除--with-curlwrapper并对其进行了重建,解决了服务器上的这一问题(在Fedora 14上运行PHP 5.3.3).

I fixed this issue on my server (running PHP 5.3.3 on Fedora 14) by removing the --with-curlwrapper from the PHP configuration and rebuilding it.

这篇关于file_get_contents返回空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆