当前位置: 首页 > 图文教程 > 网络编程 > PHP > 删除无限级目录与文件代码共享

PHP
PHP中在数据库中保存Checkbox数据(1)
VFP与其他应用程序的集成
用PHP生成自己的LOG文件
用PHP实现文件上传二法
第七节 类的静态成员 [7]
第十三节 对象串行化 [13]
用 php 编写的日历
php+dbfile开发小型留言本
第十四节 命名空间 [14]
第十二节 类的自动加载 [12]
第十一节 重载 [11]
PHP4之真OO
在apache下限制每个虚拟主机的并发数!!!!
跟我学小偷程序之成功偷取首页(第三天)
在PHP中使用XML
使用PHP模拟HTTP认证
一个阿拉伯数字转中文数字的函数
通过对php一些服务器端特性的配置加强php的安全
在Zeus Web Server中安装PHP语言支持
PHP中实现图片的锐化

PHP 中的 删除无限级目录与文件代码共享


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 78 ::
收藏到网摘: n/a

<?
//删除目录
//本程序由wm_chief原创,如要转载,请注明作者与来源(http://www.phome.net)
class del_path
{
function wm_chief_delpath($del_path)
{
if(!file_exists($del_path))//目标目录不存在则建立
{echo"目录不存在";return false;}
$hand=opendir($del_path);
$i=0;
while($file=readdir($hand))
{$i++;
if($i==1||$i==2)
{continue;}
if(!(strchr($file,".")))
{
$del_s_path=$del_path."/".$file;
$this->wm_chief_delpath($del_s_path);
}
else
{
$del_file=$del_path."/".$file;
$this->wm_chief_file($del_file);
}
}
closedir($hand);
$this->wm_chief_path($del_path);
return true;
}
//删除文件
function wm_chief_file($del_file)
{
unlink($del_file);
}
//删除目录
function wm_chief_path($del_path)
{
rmdir($del_path);
}
}
$DelPath="DelPath";//要删除的目录
$wm_chief=new del_path();
$wm_chief_ok=$wm_chief->wm_chief_delpath($DelPath);
if($wm_chief_ok)
{
echo"删除完毕";
}