代码之家  ›  专栏  ›  技术社区  ›  Steven Oxley

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

  •  2
  • Steven Oxley  · 技术社区  · 16 年前

    这是确切的问题。我有一个自动加载函数,它是用如下代码设置的:

    if(file_exists($class_file))
    {
        include($class_file);
        return true;
    }
    

    然而,何时 $class_file 设置为某个值时,我得到一个include错误:

    Error String: include(includes/php/utilities/calendar_event_html.utility.php)
    [function.include]: failed to open stream: No such file or directory
    

    它对其他文件也很好,当我使用调试器逐步完成这段代码时,很明显PHP相信该文件存在,但看起来 include 没有。有人知道发生了什么事吗?

    2 回复  |  直到 16 年前
        1
  •  9
  •   halfdan    16 年前

    从手册中:

    Note: The check is done using the real UID/GID instead of the effective one. 
    

    这意味着该文件可能存在,但您的PHP实例使用的uid/gid可能无法访问该文件。我建议您检查该文件的权限。

    最美好的祝福,
    费边

        2
  •  0
  •   simeonwillbanks    16 年前

    尝试添加此位调试代码:

    echo "<pre>";
    echo get_include_path();
    echo "</pre>";
    

    function.get-include-path

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