PHP判断文件或目录是否存在的方法
使用file_exists()函数判断文件是否存在
$file = "check.txt";
if(file_exists($file)){
echo "当前目录中,文件".$file."存在";
}else{
echo "当前目录中,文件".$file."不存在";
}
使用is_dir()函数判断目录是否存在
$dir = "check";
if(is_dir($dir)){
echo "当前目录下,目录".$dir."存在";
}else{
echo "当前目录下,目录".$dir."不存在";
} 2016-04-08 2893人浏览

评论