1, pass plan law:
It is quotative content below: DeleteDir($ Dir) {Dir of If (rmdir($ )==False &&Is_dir($ Dir)) {Dir)) {of $ of Dp = Opendir(of If ($Dp)) of $ of File=readdir(of While (($ ! = False) {File) & of If (is_dir($&$ File! =’ . ‘ &&$ File! =’ . . ‘) {DeleteDir($ File); } Else {Unlink($ File); } }Closedir($ Dp); } Else {Exit(’Not Permission’); } } } |
2, the system calls a way
It is quotative content below: Dir of Function Del_dir($ ) {If(strtoupper(substr(PHP_OS, 0, 3) )==’WIN’) { $ Str = “rmdir /s/q ” . $ Dir; } Else { $ Str = “rm -Rf ” . $ Dir; } } |
3, circular law
| It is quotative content below:
Pathdir of Function Deltree($ ) {When I debug Pathdir;// of Echo $ , useIf If(is_empty_dir($ Pathdir))// is empty {Rmdir($ Pathdir);// is deleted directly }Else {// reads this list otherwise, besides. And. . Outside $ D=dir($ Pathdir);D->read() of $ of While($ A= ) {If(is_file($ Pathdir. ‘/’ . $ A) &&($ A! =’ . ‘) &&($ A! =’ . . ‘)){unlink($ Pathdir. ‘/’ . $ A);} / / if be a file,delete directlyIf(is_dir($ Pathdir. ‘/’ . $ A) &&($ A! =’ . ‘) &&($ A! =’ . . ‘) ) If {// is catalogIf(! Is_empty_dir($ Pathdir. ‘/’ . Whether $ A))// is empty If {// is not, call oneself, the method that was before nevertheless his inferior catalog nameDeltree($ Pathdir. ‘/’ . $ A); }If(is_empty_dir($ Pathdir. ‘/’ . $ A) ) If {// is empty delete directlyRmdir($ Pathdir. ‘/’ . $ A); } } } $ D->close();Echo ” must delete what when I debug all file ” ;// below catalog, use first } }Pathdir of Function Is_empty_dir($ ) { / / whether judgement catalog is empty, is my method very good? Just look besides. And. . There is other thing besides is not to be empty Pathdir); of $ D=opendir($ $ I=0;D) of $ of While($ A=readdir() { $ I ; }Closedir($ D);If($ I>2){return False;}Else Return True; }
|