php 包含():无法打开流:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9557945/
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
include(): Failed to open stream: No such file or directory
提问by Namit
This might just come as a very silly question, but i am really frustrated of this not working.
I have a home file (home.php)
which has contains <? include ("/production/fetch_order.php"); ?>
. As it can be seen i am trying to access a file from home.php. The file is named as fetch_order.php
which is in the production folder. My path is correct, the spellings are absolutely correct too. However i end up with this error:
这可能只是一个非常愚蠢的问题,但我真的很沮丧这不起作用。我有一个(home.php)
包含<? include ("/production/fetch_order.php"); ?>
. 可以看出,我正在尝试从 home.php 访问文件。该文件被命名为fetch_order.php
位于生产文件夹中。我的路径是正确的,拼写也绝对正确。但是我最终遇到了这个错误:
Warning: include(/production/fetch_order.php) [function.include]:
failed to open stream: No such file or directory in /path/to/home.php on line 119
Warning: include() [function.include]: Failed opening '/production/fetch_order.php'
for inclusion (include_path='.:/path/to/php/php5.3.6/lib/php') in
/path/to/home.php on line 119
回答by MacMac
You are using an absolute path (/
) at the start of the line, you need to remove that slash and it would be a relative path, example:
您/
在该行的开头使用了绝对路径 ( ),您需要删除该斜杠,它将是一个相对路径,例如:
production/fetch_order.php
When adding a slash, it starts at the root directory of your system, without it, it looks in the current directory.
添加斜杠时,它从系统的根目录开始,没有它,它会在当前目录中查找。
回答by rjz
Make sure that the path you're referencing ('/production/fetch_order.php') is provided eitheras an absolute path from the file system root directory or as a relative path from the current file (home.php
).
请确保您引用(“/production/fetch_order.php”)的路径,提供无论是从文件系统的根目录的绝对路径或从当前文件的相对路径(home.php
)。
include('production/fetch_order.php');
OR
或者
include(dirname(__FILE__) . '/production/fetch_order.php');
回答by dotoree
Seems that path is not correct, try:
似乎路径不正确,请尝试:
<? include ("production/fetch_order.php"); ?>