无法打开“../tweets.php”以进行包含(include_path='.:')
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14861828/
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 opening '../tweets.php' for inclusion (include_path='.:')
提问by AppleTattooGuy
I am trying to include a script using the following code.
我正在尝试使用以下代码包含脚本。
<div class="main_content">
<?php include ('tweets.php') ?>
</div>
But it keeps throwing up the following error.
但它不断抛出以下错误。
Warning: include(tweets.php): failed to open stream: No such file or directory in - on line 52 Warning: include(): Failed opening 'tweets.php' for inclusion (include_path='.:') in - on line 52
警告:include(tweets.php):无法打开流:第 52 行中没有这样的文件或目录第 52 行
I have checked and double checked and the file definitely exists and is in the same directory as the file that this is in.
我已经检查并仔细检查过,该文件确实存在并且与它所在的文件位于同一目录中。
I really appreciate your help on this.
我真的很感谢你在这方面的帮助。
采纳答案by Josh
The path is relative to the file where the request was initiated. So, even if it's in the same folder as the file it's including, if that file was included from a file in a different folder, you will have to use an absolute path or a path relative to the original file.
该路径相对于发起请求的文件。因此,即使它与包含的文件位于同一文件夹中,如果该文件是从不同文件夹中的文件包含的,您也必须使用绝对路径或相对于原始文件的路径。
回答by neelsg
Try using include('./tweets.php');. If that does not resolve your issue, it's most likely file permissions. Give everyone full permissions for tweets.php and see if that works.
尝试使用include('./tweets.php');. 如果这不能解决您的问题,则很可能是文件权限。授予每个人对 tweets.php 的完全权限,看看是否有效。
回答by Andrea
As @Josh says, the path is relative to the file that received the request, so you can exploit the PHP __DIR__magic constant:
正如@Josh 所说,路径是相对于收到请求的文件而言的,因此您可以利用 PHP__DIR__魔法常量:
include(__DIR__ . '/tweets.php');
回答by Whorton Eloisa
same message but i fix it...cleaning all the blank spaces before and after php symbols
<?phpand?>make sure
{and}are not missing and where they need to bemake sure this syntax is correctly where it need to be
{and<?php } ?>No need for an extra path... Thank You very much
相同的消息,但我修复了它...清除 php 符号前后的所有空格
<?php和?>确保
{并}没有失踪,在那里他们需要确保此语法正确位于需要的位置
{并且<?php } ?>不需要额外的路径...非常感谢
Warning: include(tweets.php): failed to open stream: No such file or directory in - on line 52 Warning: include(): Failed opening 'tweets.php' for inclusion (include_path='.:') in - on line 52
警告:include(tweets.php):无法打开流:第 52 行中没有这样的文件或目录第 52 行
回答by Whorton Eloisa
1.)if you have 2 different variables is a different scenario like same name one variable with upper case and one variable with lower case...different solution you are right thank you very much
1.) 如果你有 2 个不同的变量是一个不同的场景,比如同名一个大写的变量和一个小写的变量......不同的解决方案,你是对的,非常感谢
2.)but if someone could change the variables to be complete different variables names they may not have that problem....not always the case
2.)但是如果有人可以将变量更改为完整的不同变量名称,他们可能不会有这个问题......并非总是如此
回答by Insekai
That's because your file name not found due to "case sensitive". Example "./Core/admin.php" and "./core/admin.php" are diffrent.
那是因为由于“区分大小写”而找不到您的文件名。例如“./Core/admin.php”和“./core/admin.php”是不同的。

