PHP determines whether a file exists in a specified directory

    /*
        Function: determine whether a file exists in a directory;
        Parameters: $path - the directory to be judged, using an absolute path
        Return value: exists - true does not exist - false
    */
    function dir_exist_file($path) {
        if(!is_dir($path)) {
            return false;
        } else {
            $files = scandir($path);
            // remove "." and ".."
            unset($files[0]);
            unset($files[1]);
            // determine if it is empty
            if(!empty($files[2])) {
                return true;
            }else{
                return false;
            }
        }
    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325851377&siteId=291194637