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

PHP
如何学习一个新的PHP框架
配置最新的PHP加MYSQL服务器
PHP原版HTML编码器溢出问题的解决
PHP-Javascript“返回上一页”无缓存问题
基于DB2及PHP的应用系统跨平台迁移详细步骤(一)
基于DB2及PHP的应用系统跨平台迁移详细步骤(二)
PHP Squid中可缓存的动态网页设计
PHP读取文件夹内有多少个文件
PHP Header用于页面跳转要注意的几个问题总结
一些使用频率比较高的PHP函数
PHP5.2下preg_replace函数的问题
PHP-Push技术实现刷新功能
PHP动态图像的创建
PHP中重新定向到另一个页面
在PHP中将图片存放ORACLE中
PHP开发大型Web应用浅析
PHP正则相关的几个preg函数
PHP开发中最常见的文件操作疑难解答
面向普通人加密 使用PHP应用程序保护数据
记录PHP网站开发几个好功能

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 53 ::
收藏到网摘: 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"删除完毕";
}