The PHP recursive delete folder function was written two times. The first execution did not delete successfully, need to delete successfully ... So it should be a failure, the code is as follows:
<span style= "color: #FF0000;" >//Delete File method Private function Rmdirs ($val) {rmdir ($val); if (!file_exists ($val)) {return false;} if (Is_file ($val) | | Is_link ($val)) {return unlink ($val);} if (Is_dir ($val)) {if ($dir = Opendir ($val)) {while ($file = Readdir ($dir)) {if ($file = = ". ' | | $file = = ' ... ') {continue;} $path = $val. '/'. $file; unlink ($path); $this->rmdirs ($path);} Closedir ($val);}} --></span>
The correct code is as follows:
/** * Recursive deletion of files * $path Incoming folder addresses to be deleted */<span style= "color: #33CC00;" >function Deldir ($path) {if (Is_dir ($path)) {$file _list = Scandir ($path); foreach ($file _list as $file) {if ($file! = '). && $file! = ' ... ') {Deldir ($path. ') /'. $file);//recursively delete echo ' <font color= ' Blue > '. $path. ' /'. $file. ' File cleanup succeeded!</font><br> ';}} @rmdir ($path);//Delete empty directory}else{@unlink ($path);//delete file}}</span>
PHP Recursive Delete folder