PHP clarifation of file_exists函数,它是检查实际文件还是只检查路径

PHP clarifation of file_exists函数,它是检查实际文件还是只检查路径,php,sql,file,path,file-exists,Php,Sql,File,Path,File Exists,我在SQL数据库中有一个txt文件名和路径列表。我有一个只包含几个文件的目录(很多链接都是坏链接)。我正在使用: $filename = '/path/somename.txt'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } 检查文件,但我注意到它总是像文件在那里一样返回。对于我正在尝试做的事情,这个函数

我在SQL数据库中有一个txt文件名和路径列表。我有一个只包含几个文件的目录(很多链接都是坏链接)。我正在使用:

$filename = '/path/somename.txt';

if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}

检查文件,但我注意到它总是像文件在那里一样返回。对于我正在尝试做的事情,这个函数是否有更好的替代方案,或者我是否做了其他错误的事情。提前谢谢你

文件存在
应验证文件存在,而不仅仅是文件路径存在

如果遇到问题,可以尝试将文档根目录包含在路径中。

尝试以下操作:

$filename = dirname(__FILE__)."/path/somename.txt";

 echo  file_exists($filename) ? "The file $filename exists" : "The file $filename does not exist";