function del_dir($dir) { if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $str = "rmdir /s/q " . $dir; } else { $str = "rm -Rf " . $dir; } exec($str,$output,$retval); //$retval 0 命令执行成功 其它表示出错 return $retval==0; }