使用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。
答案 0 :(得分:2)
对于因安全模式限制而无法访问的文件,此函数返回FALSE
。
在文件路径中使用$_SERVER['DOCUMENT_ROOT']
变量。
答案 1 :(得分:1)
尝试使用相对路径ex : $_SERVER['DOCUMENT_ROOT']
而不是绝对路径
答案 2 :(得分:0)
关于 file_exists() Php.net声明
对于因安全模式限制而无法访问的文件,此函数返回FALSE。但是,如果这些文件位于safe_mode_include_dir中,则仍可以包含这些文件。
这可以解释包含工作和存在检查没有的事实。
答案 3 :(得分:-1)
$list
可能设置不正确。你试过$list="class.data.".$list.".php";
吗?