php 删除目录及子文件

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;
}

  

posted @ 2016-12-12 16:43  male110  阅读(74)  评论(0编辑  收藏  举报