/** |
* 用递归方式删除目录 |
* |
* @param string $file |
* @return boolean |
*/ |
public static function rm_recurse( $file ){ |
if ( strpos ( $file , '..' ) !== false){ |
return false; |
} |
if ( is_dir ( $file ) && ! is_link ( $file )){ |
foreach (scandir( $file ) as $sf ){ |
if ( $sf === '..' || $sf === '.' ){ |
continue ; |
} |
if (!self::rm_recurse( $file . '/' . $sf )){ |
return false; |
} |
} |
return @ rmdir ( $file ); |
} else { |
return unlink( $file ); |
} |
} |