php删除指定目录下的的文件/文件夹-用PHP怎么删除某目录下指定的一个文件/文件夹?
1
2 $dir = '你要删除的目录路径'; //如下:
3 //$dir = $_SERVER['DOCUMENT_ROOT'].'/cache';
4 rmdirs($dir);
5
6 //php删除指定目录下的的文件-用PHP怎么删除某目录下指定的一个文件?
7 function rmdirs($dir){
8 //error_reporting(0); 函数会返回一个状态,我用error_reporting(0)屏蔽掉输出
9 //rmdir函数会返回一个状态,我用@屏蔽掉输出
10 $dir_arr = scandir($dir);
11 foreach($dir_arr as $key=>$val){
12 if($val == '.' || $val == '..'){}
13 else {
14 if(is_dir($dir.'/'.$val))
15 {
16 if(@rmdir($dir.'/'.$val) == 'true'){} //去掉@您看看
17 else
18 rmdirs($dir.'/'.$val);
19 }
20 else
21 unlink($dir.'/'.$val);
22 }
23 }
24 }
25 ?>
php删除指定目录下的文件夹和文件-用PHP怎么删除某目录下指定的一个文件夹和文件?
作者 网宗

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

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

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
