php判断文件或目录(文件夹)是否存在

来自:互联网
时间:2020-02-20
阅读:

 php库自带有判断文件或目录是否存在的函数,file_exists判断文件是否存在,is_dir判断目录(文件夹)是否存在。具体示例如下:

$file='index.php';
$dir='www.freexyz.cn/wwwroot/';
if(file_exists($dir.$file)){
	echo '文件'.$file.'存在';
}else{
	echo '文件'.$file.'不存在';
}
if(is_dir($dir)){
    echo '目录'.$dir.'存在';
}else{
    echo '目录'.$dir.'不存在';
}
返回顶部
顶部