开发者

Why is PHP not including my file when it clearly exists?

开发者 https://www.devze.com 2022-12-13 08:40 出处:网络
Here is the exact problem.I have an autoload function set up with a piece of code that looks like this:

Here is the exact problem. I have an autoload function set up with a piece of code that looks like this:

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

However, when $class_file is set to a certain value, I get an include error:

Error String: include(includes/php/utiliti开发者_JAVA百科es/calendar_event_html.utility.php)
[function.include]: failed to open stream: No such file or directory

It works fine for other files and when I step through this code with a debugger it is clear that PHP believes the file exists, but it seems that include does not. Does anyone have an idea of what is going on?


From the manual:

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

This means that the file may exist, but it's possible that it is not accessible by the UID/GID your PHP instance is running with. I suggest you check the permissions to that file.

Best wishes,
Fabian


Try adding this bit of debugging code:

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

function.get-include-path

This will return your current include path, and you can compare it with your $class_file string.

0

精彩评论

暂无评论...
验证码 换一张
取 消