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

PHP
PHP图片上传类带图片显示
用PHP中的 == 运算符进行字符串比较
使PHP自定义函数返回多个值
在PHP中使用与Perl兼容的正则表达式
PHP中的cookie
PHP 应用程序的安全 -- 不能违反的四条安全规则
PHP date函数参数详解
PHP读写文件的方法(生成HTML)
PHP如何得到当前页和上一页的地址?
PHP完整的日历类(CLASS)
php类
mysq GBKl乱码
php字符串截取问题
PHP+AJAX实现无刷新注册(带用户名实时检测)
windows xp下安装pear
专为新手写的结合smarty的类
PHP 中的面向对象编程:通向大型 PHP 工程的办法
数组处理函数库
PHP 选项及相关信息函数库
PHP 已经成熟

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


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

php下需要删除多级目录的朋友及可以参考下面的类 <?
//删除目录
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"删除完毕";
}
?>