【发布时间】:2013-03-23 14:05:45
【问题描述】:
当使用file_exists()时,它总是返回false。但该文件确实存在并且可以使用require 加载。这是我的代码:
// Creating dependency lists.
$data_dependency = array("mysql", "oracle", "postgresql", "sqlite", "access");
// Calling the dependecny files.
foreach ($data_dependency as $list) {
$list = "class.data.$list.php";
_system::debug("Calling required class $list ...");
if (file_exists($list)) {
include($list);
_system::debug("Calling $list was successfull.");
} else {
_system::debug("Calling $list was failed. Now we close the system load.");
exit("Calling $list was failed. Now we close the system load.");
}
}
当我加载页面时,页面总是exit()。我认为原因是file_exists() 函数总是返回false。
【问题讨论】:
-
尝试使用绝对路径。
-
你说文件单数存在,但你正在寻找 5,如果任何一个不存在它就会退出
-
@Calum - 我尝试使用绝对路径,但仍然是错误的。
-
@Crisp - 但所有文件都存在于我的文件夹中。如果我不检查它并直接包含它,则所有文件都已正确加载。
-
您是否检查了调试输出以查看它失败的原因?另外,您确定文件存在于 当前目录 或 包含路径 中并且您有权访问它们吗?如果您从另一个目录包含此代码,则 当前目录 不是包含文件所在的目录