PHP5提供打开流失败

PHP5提供打开流失败

本文介绍了PHP5提供打开流失败:使用fopen时HTTP请求失败错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题似乎过去在Google和此处的所有地方都曾讨论过,但我还没有找到解决方法.

This problem seems to have been discussed in the past everywhere on google and here, but I have yet to find a solution.

一个非常简单的fopen给我一个

A very simple fopen gives me a

我获取的URL不重要,因为即使我获取 http://www.google.com 它不起作用.完全相同的脚本可在不同的服务器上运行.一个失败的是Ubuntu 10.04和PHP 5.3.2.这不是我的脚本中的问题,它与服务器中的内容有所不同,或者可能是PHP中的错误.

The URL I am fetching have no importance because even when I fetch http://www.google.com it doesnt work. The exact same script works on different server. The one failing is Ubuntu 10.04 and PHP 5.3.2. This is not a problem in my script, it's something different in my server or it might be a bug in PHP.

我尝试在php.ini中使用user_agent,但没有成功.我的allow_url_fopen设置为开".

I have tried using a user_agent in php.ini but no success. My allow_url_fopen is set to On.

如果您有任何想法,请放心!

If you have any ideas, feel free!

推荐答案

这听起来像您的配置不允许使用文件功能,由于安全方面的考虑,如今这很普遍.如果您有可用的cURL库,我建议您尝试一下.

It sounds like your configuration isn't allowed to use file functions, which is common these days because of security concerns. If you have the cURL libraries available to you, I would recommend trying those out.

PHP:cURL

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.ca/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$file = curl_exec($ch);
curl_close($ch);

echo $file;

这篇关于PHP5提供打开流失败:使用fopen时HTTP请求失败错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 22:27