PHP判断指定目录下是否存在文件

    /*
        功能:判断某个目录下是否存在文件;
        参数:$path —— 要进行判断的目录,使用绝对路径
        返回值:存在 - true  不存在 - false
    */
    function dir_exist_file($path) {
        if(!is_dir($path)) {
            return false;
        } else {
            $files = scandir($path);
            // 删除  "." 和 ".."
            unset($files[0]);
            unset($files[1]);
            // 判断是否为空
            if(!empty($files[2])) {
                return true;
            }else{
                return false;
            }
        }
    }

猜你喜欢

转载自blog.csdn.net/createno_1/article/details/80136721