Last active
February 1, 2019 02:47
-
-
Save eddy8/d229af3525e1804e0ab1b8ffa6812d21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 删除指定目录,含子目录及目录下文件 | |
* | |
* @param string $path 路径 | |
* @return void | |
*/ | |
function deleteAll($path) | |
{ | |
$di = new DirectoryIterator($path); | |
foreach ($di as $f) { | |
if ($f->isDot()) { | |
continue; | |
} | |
$name = $f->getPathName(); | |
if ($f->isDir()) { | |
deleteAll($name); | |
rmdir($name); | |
} else { | |
unlink($name); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment