11
08月
2015
31. 删除文件夹内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
function Delete ( $path )
{
if ( is_dir ( $path ) === true)
{
$files = array_diff (scandir( $path ), array ( '.' , '..' ));
foreach ( $files as $file )
{
Delete ( realpath ( $path ) . '/' . $file );
}
return rmdir ( $path );
}
else if ( is_file ( $path ) === true)
{
return unlink( $path );
}
return false;
}
|
语法:
1
2
3
4
|
<?php
$path = "images/" ;
Delete ( $path ); // This will delete images folder along with its contents.
?>
|
特殊说明,本文版权归 ning个人博客 所有带原创标签请勿转载,转载请注明出处.