两个包含来自同一文件夹。一个有效,一个没有 - PHP

时间:2014-09-18 11:30:21

标签: php include

我试图在我的PHP文件中做一些包含。我试图包含的两个文件都存在。

这个有效:

include("/folder/subfolder/firstfile.php");

这个没有:

include("/folder/secondfile.php");

这怎么可能,因为两个包括来自同一文件夹.....?

我遇到的错误

Warning: include(/folder/secondfile.php) [function.include]: failed to open stream: No such file or directory in index.php on line 2

Warning: include() [function.include]: Failed opening '/folder/secondfile.php' for inclusion (include_path='.:/usr/local/lib/php') in index.php on line 2

文件结构

Root中包含folder。包含文件位于根目录中的另一个文件夹中。

1 个答案:

答案 0 :(得分:0)

第二个include()中缺少PHP扩展名。

include("/folder/secondfile");

更改为

include("/folder/secondfile.php");

还要确保它位于文件夹folder中。如果它在subfolder中,请不要忘记将其包含在以下路径中:

include("/folder/subfolder/secondfile.php");