标题:
PHP:多级目录删除
[打印本页]
作者:
Nothing
时间:
2007-7-11 11:08
标题:
PHP:多级目录删除
<
?
php
// Author: windlike
// Create Time: 2007-07-10
// Blog: windlike.cublog.cn
function
delDir
(
$
dir
)
{
$
mydir
=
dir
(
$
dir
)
;
while
(
false
!
=
=
(
$
file
=
$
mydir
-
>
read
(
)
)
)
{
if
(
(
is_dir
(
"$dir/$file"
)
)
&
&
(
$
file
!
=
"."
)
&
&
(
$
file
!
=
".."
)
)
{
delDir
(
"$dir/$file"
)
;
}
else
{
if
(
(
$
file
!
=
"."
)
&
&
(
$
file
!
=
".."
)
)
{
unlink
(
"$dir/$file"
)
;
//echo "unlink $dir/$file ok <br>";
}
}
}
$
mydir
-
>
close
(
)
;
rmdir
(
$
dir
)
;
//echo "rmdir $dir ok <br>";
}
//delDir("xxx"); // 不经过回收站,直接删除。本机测试时请慎用。
?
>
欢迎光临 编程开发论坛 (http://bbs.lihuasoft.net/)
Powered by Discuz! 6.0.0