Skip to content

Instantly share code, notes, and snippets.

@eddy8
Last active February 1, 2019 02:47
Show Gist options
  • Save eddy8/d229af3525e1804e0ab1b8ffa6812d21 to your computer and use it in GitHub Desktop.
Save eddy8/d229af3525e1804e0ab1b8ffa6812d21 to your computer and use it in GitHub Desktop.
<?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