为什么get_file_contents不起作用? [英] Why get_file_contents not working?

查看:81
本文介绍了为什么get_file_contents不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部。我是PHP的新手。虽然我通过这个论坛挖掘试图找到get_file_contents函数的答案,但我失败了。请帮助解决以下问题。


我正在测试使用谷歌地图api构建页面来从新闻网站检索数据并在谷歌地图上绘制标记。由于新闻不断更新,我在服务器端使用脚本代理获取远程文件,用户的浏览器将动态解析数据并加载结果。链接位于:

<已删除链接>

问题是当我使用get_file_contents(远程目标文件)时,会出现警告无法打开流。 .."我想要一个可靠的方法来获取文件,有些人在PHP ini fopen中将其识别为OFF,看起来并不那么简单。我需要一种方法来检测ISP是否已禁用fopen功能。


或者您可以建议其他方法来解决此问题,并在每次浏览器加载地图时获取文件。


非常感谢您提前。

我们将不胜感激。

Hi, All. I am new to PHP. Though I dug through this forum to try to find an answer to get_file_contents function, I failed. Please help with the below problem.

I am testing building a page by using google maps api to retrieve data from a news site and plotting markers on google map. Because the news is constantly updated, i used script proxy on server side to get remote file, the user''s brower will dynamically parse the data and load the result. The link is at:
<Link removed>
The problem is that when I use get_file_contents(remote target file), there is warning "Failed to open stream..." I want a reliable way to get the file, some identified it as OFF in PHP ini fopen, it seems not that simple. And I need a method to detect if ISP has disabled fopen function.

Or you may suggest other ways to workaround this and get the file each time the browser loads the map.

Thank you very much in advance.
Your any help will be appreciated.

推荐答案

嗨。欢迎来到The Scripts!


我从你的帖子中删除了链接。技术论坛严格禁止所有商业网站链接。有关我们的发布政策的更多信息,请阅读发布指南。 />

好​​的,解决问题。

你能发布你得到的错误消息吗?

也许正在生成的代码它们?


另外,请记住,大多数文件系统函数都需要启用php.ini中的''allow_url_fopen''指令才能打开URL。 />

要测试这个,只需执行此代码即可。如果它打印0则禁用。 1表示已启用。
Hi. Welcome to The Scripts!

I removed the link from your post. All links to commercial webs are strictly forbidden on the technical forums. Please read the Posting Guidelines for more info on our posting policies.

Ok, getting to the problem.
Could you post the error messages you are getting?
And maybe the code that is generating them?

Also, keep in mind that most of the file system functions require the ''allow_url_fopen'' directive in your php.ini to be enabled in order to open URLs.

To test this, simply execute this code. If it prints 0 it is disabled. 1 means it is enabled.
展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


非常感谢.Ati。


错误警告是

警告:file_get_contents(远程网址):无法打开流:HTTP请求失败!在第3行的D:\wwwroot \guoshesen \ www.root \ map \ rssxml.php中找不到HTTP / 1.1 404


因为该远程URL是一个xml文件,我可以在我的IE中顺利打开它,但不能通过php代理脚本打开..
Thank you very much.Ati.

error warning is
Warning: file_get_contents(remote url): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in D:\wwwroot\guoshesen\wwwroot\map\rssxml.php on line 3

As that remote url is an xml file, I can smoothly open it in my IE but not through php proxy script..


Heya,1965。


你得到的是404 ,这意味着您请求的URL不存在。


尝试回显您的URL以确保您传递给file_get_contents()您认为您''传递给file_get_contents()。
Heya, 1965.

You''re getting a 404, which means that the URL that you''re requesting doesn''t exist.

Try echoing your URL to make sure you''re passing to file_get_contents() what you think you''re passing to file_get_contents().


这篇关于为什么get_file_contents不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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