search
Homephp教程php手册PHP删除目录及目录下所有文件或删除指定文件

PHP删除目录及目录下所有文件或删除指定文件
/**<br>  * 删除目录及目录下所有文件或删除指定文件<br>  * @param str $path   待删除目录路径<br>  * @param int $delDir 是否删除目录,1或true删除目录,0或false则只删除文件保留目录(包含子目录)<br>  * @return bool 返回删除状态<br>  */<br> function delDirAndFile($path, $delDir = FALSE) {<br>     $handle = opendir($path);<br>     if ($handle) {<br>         while (false !== ( $item = readdir($handle) )) {<br>             if ($item != "." && $item != "..")<br>                 is_dir("$path/$item") ? delDirAndFile("$path/$item", $delDir) : unlink("$path/$item");<br>         }<br>         closedir($handle);<br>         if ($delDir)<br>             return rmdir($path);<br>     }else {<br>         if (file_exists($path)) {<br>             return unlink($path);<br>         } else {<br>             return FALSE;<br>         }<br>     }<br> }本文固定链接: http://www.seo0395.com/archives-219
转载请注明: 潘工 2015年09月11日 于 潘军伟博客 发表

AD:真正免费,域名+虚机+企业邮箱=0元

Statement
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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function