1
2 $dir = ' directory path you want to delete '; As follows:
3//$dir = $_server[' Document_root '). ' /cache ';
4 Rmdirs ($DIR);
5
6//php Delete files in the specified directory-How do I delete a file specified under a directory in PHP?
7 function Rmdirs ($dir) {
8//error_reporting (0); function returns a state, I use error_reporting (0) to mask out the output
9//rmdir function will return a state, I use @ mask out the output
Ten $dir _arr = Scandir ($dir);
One foreach ($dir _arr as $key + = $val) {
if ($val = = '. ' | | $val = = ' ... ') {}
else {
if (Is_dir ($dir. '/'. $val))
15 {
if (@rmdir ($dir. '/'. $val) = = ' true ') {}//Remove @ You see
+ Else
Rmdirs ($dir. '/'. $val);
19}
Else
Unlink ($dir. '/'. $val);
22}
23}
24}
?>
PHP Delete folders and files under the specified directory-How do I delete a folder and file specified under a directory in PHP?
Author Web Parcel
http://www.bkjia.com/PHPjc/478536.html www.bkjia.com true http://www.bkjia.com/PHPjc/478536.html techarticle 1. php 2 $dir = The directory path you want to delete,//as follows: 3//$dir = $_server[document_root]./cache; 4 rmdirs ($dir); 5 6//php Delete the file under the specified directory-PHP how Delete a directory ...