class RmoveDir{
// 删除文件夹, 同时删除文件夹下的所有文件
public function rm_dir($path)
{
if(!file_exists($path))
{
$this->set_error( $path.' 不存在' );
return false;
}
if ( is_dir($path) )
{
$handle = opendir($path);
while (($file = readdir($handle)) !== false)
{
if( $file != '.' && $file != '..' )
{
$this->rm_dir( $path.DS.$file );
}
}
closedir($handle);
rmdir($path);
}
else
{
unlink($path);
}
return true;
}
}
PHP代码删除文件夹目录
最新推荐文章于 2022-06-21 22:18:36 发布