php 无法打开流:找不到合适的包装器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19527150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
failed to open stream: no suitable wrapper could be found
提问by Tomek
hello i am implementing php files from one website into another and here is the following error message i am getting when trying to open the following page with implemented php files:
您好,我正在将 php 文件从一个网站实施到另一个网站,这是我在尝试使用实施的 php 文件打开以下页面时收到的以下错误消息:
http://www.holidaysavers.ca/europe-destinations-canada.php
http://www.holidaysavers.ca/europe-destinations-canada.php
basically the php files i am importing from one website into another are identical , however they work on the original website but when i implement them into a new website it does not work anymore.
基本上,我从一个网站导入到另一个网站的 php 文件是相同的,但是它们在原始网站上工作,但是当我将它们实施到一个新网站时,它不再起作用。
could you assist me in trying to get this resolved?
你能帮我解决这个问题吗?
thank you
谢谢你
回答by Latheesan
You can't include a PHP script that is on an external website/server into your local script - unless you enable allow_url_include
on your php.ini
(if you have access to it)
你可以不包括PHP脚本,是一个外部网站/服务器到本地脚本上-除非你能allow_url_include
在你php.ini
(如果你有机会的话)
Instead, you can let that website/server render the page and get the resulting html output on your local script.
相反,您可以让该网站/服务器呈现页面并在您的本地脚本上获取生成的 html 输出。
Replace this line in your script:
替换脚本中的这一行:
include('http://www.holidaysavers.ca/europe-canada.php?detour');
With this:
有了这个:
echo file_get_contents('http://www.holidaysavers.ca/europe-canada.php?detour');
回答by ldmo
Could you post the code from "europe-destinations-canada.php"? It looks like the script is asking to do stuff that's not configured in your php setup on this new site/server
你能把“europe-destinations-canada.php”的代码贴出来吗?看起来该脚本要求执行此新站点/服务器上的 php 设置中未配置的操作
回答by Jonathan J. Pecany
I don't really know what kind of host you are using or if you are using Xampp, I do have an easy fix to it, for xampp and possibly other web server software. Go to your php.ini file, which you can search for or just look for it in c:\\xampp\php\php.ini
, the php.ini
should be in the php folder in the server software folder. Now search for allow_url_include
in the php.ini file and than replace Off with On, if it isn't already on or something. This is most likely the fix because it worked for me.
我真的不知道您使用的是哪种主机,或者您是否使用 Xampp,我确实有一个简单的修复方法,适用于 xampp 和可能的其他 Web 服务器软件。转到您的 php.ini 文件,您可以在 中搜索或查找它c:\\xampp\php\php.ini
,该文件php.ini
应该位于服务器软件文件夹中的 php 文件夹中。现在allow_url_include
在 php.ini 文件中搜索,然后用 On 替换 Off,如果它尚未打开或其他内容。这很可能是修复方法,因为它对我有用。
I might be able to help further if I know if you are using a hosting or home server. If you are using a hosting website than please share what kind of hosting service you are using so I could inspect it further.
如果我知道您使用的是托管服务器还是家庭服务器,我可能会提供更多帮助。如果您使用的是托管网站,请分享您使用的托管服务类型,以便我进一步检查。
回答by Jonathan J. Pecany
Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/content/91/8151691/html/HolidaySavers.ca/europe-destinations-canada.php on line 52
says it all. I believe this is called XXS. It appears you're attempting to include a URL based file which is denied in your server configuration which is either one of two things.
都说了。我相信这被称为XXS。您似乎正在尝试包含一个基于 URL 的文件,该文件在您的服务器配置中被拒绝,这是两件事之一。
You're attempting to include the file on site B from site A which you would then use instead of
include('WhateverFile');
file_get_contents('WhateverFile');
however this will only return the client side data as it is an HTTP request;You've duplicated the file on site B and forgot to update the domain configuration. Be sure that the include path reflects the site you're running the script on ie.
include(dir($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'WhateverFile.php');
您正在尝试从站点 A 中包含站点 B 上的文件,然后您将使用该文件而不是,
include('WhateverFile');
file_get_contents('WhateverFile');
这只会返回客户端数据,因为它是一个 HTTP 请求;您已复制站点 B 上的文件,但忘记更新域配置。确保包含路径反映了您在 ie 上运行脚本的站点。
include(dir($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'WhateverFile.php');
In any case. I would have to actually examine the line 52 on the said file to see why PHP is complaining to you in detail lol
任何状况之下。我将不得不实际检查上述文件中的第 52 行,以了解 PHP 为何向您详细抱怨,哈哈