当我的文件明显存在时,为什么PHP不包括它?

当我的文件明显存在时,为什么PHP不包括它?,php,include,Php,Include,这就是确切的问题。我有一个自动加载功能,设置的代码如下: if(file_exists($class_file)) { include($class_file); return true; } 但是,当$class_file设置为某个值时,我得到一个包含错误: Error String: include(includes/php/utilities/calendar_event_html.utility.php) [function.include]: failed to op

这就是确切的问题。我有一个自动加载功能,设置的代码如下:

if(file_exists($class_file))
{
    include($class_file);
    return true;
}
但是,当
$class_file
设置为某个值时,我得到一个包含错误:

Error String: include(includes/php/utilities/calendar_event_html.utility.php)
[function.include]: failed to open stream: No such file or directory
它可以很好地处理其他文件,当我使用调试器逐步处理这段代码时,很明显PHP相信该文件存在,但似乎
include
不存在。有人知道发生了什么吗?

手册:

Note: The check is done using the real UID/GID instead of the effective one. 
这意味着该文件可能存在,但可能无法通过运行PHP实例的UID/GID访问该文件。我建议您检查该文件的权限

最美好的祝愿,

Fabian

尝试添加以下调试代码:

echo "<pre>";
echo get_include_path();
echo "</pre>";
echo”“;
echo get_include_path();
回声“;


这将返回您当前的include路径,您可以将其与$class_文件字符串进行比较。

也许PHP没有访问此文件的权限?@ApoY2k您可以在错误中看到,内容是
includes/PHP/utilities/calendar_event_html.utility.PHP
,但是它可以很好地处理
includes/php/utilities/calendar\u header\u html.utility.php
——这两种代码都必须存在,因为我之前在做
file\u exists
。上面的代码真的与您在应用程序中使用的代码相同吗?如果不是,包含是否发生在文件_存在之外的其他文件中?@halfdan是的,实际上是一样的。我在Windows上,所以我认为权限不会有问题(以前从来没有过),但是我用Cygwin复制了这个特定的文件-我想知道当我这么做的时候它是否改变了文件的权限…你能在另一台机器上复制这个行为吗?我没有试过,但是我用Cygwin复制的一些javascript文件也有类似的问题。