PHP剔除文件
Jun 13, 2016 am 11:00 AM
dir
dirname
file
PHP删除文件
???? 这是一个很不错的PHP删除文件类,很实用,跟大家分享,我过去PHP菜的时候找这个就找了好久呢,呵呵
?
<?php//创建删除文件类class DELFILE{function removeDir($dirName) { if(! is_dir($dirName)) //判断指定目录是存在 { @unlink($dirName); return false; } $handle = @opendir($dirName); //打开目录 while(($file = @readdir($handle)) !== false) { if($file != '.' && $file != '..') //列出目录中的所有文件并去掉 . 和 .. { $dir = $dirName . '/' . $file; is_dir($dir) ? removeDir($dir) : @unlink($dir); //删除指定目录中的文件 } } closedir($handle); //关闭由opendir()打开的目录 return rmdir($dirName) ; //rmdir()删除空目录 } }$ob_del=new DELFILE(); //实例化类$dirName="G:/123/123.jpg"; //这里是指定的路径$ob_del->removeDir($dirName); //执行方法/*----------------------------------------------*//*------------------结束------------------------*//*-----------------------------------------------*/?>
Copy after login
?
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Hongmeng native application random poetry

Use java's File.length() function to get the size of the file

Rename files using java's File.renameTo() function

Use java's File.getParentFile() function to get the parent directory of the file

Use java's File.getParent() function to get the parent path of the file

How to delete a file or directory using File.delete() method in Java?

WebView File Domain Origin Policy Bypass Vulnerability Example Analysis
