The article is very simple two instances of PHP directory creation and recursive unlimited creation and deletion of the directory function, the need for friends can refer to, we use Mkdir,rddir to instance.
Here is the program code:
The code is as follows |
Copy Code |
function Mkdirs ($dir) { if (!is_dir ($dir)) { if (!mkdirs (DirName ($dir))) { return false; } if (!mkdir ($dir, 0777)) { return false; } } return true; } Mkdirs (' div/css/layout ');
|
In the same vein, PHP uses RmDir and unlink to recursively delete the multilevel directory code:
The code is as follows |
Copy Code |
function Rmdirs ($dir) { $d = Dir ($dir); while (false!== ($child = $d->read ())) { if ($child! = '. ' && $child! = ' ... ') { if (Is_dir ($dir. '/'. $child)) Rmdirs ($dir. '/'. $child); Else unlink ($dir. '/'. $child); } } $d->close (); RmDir ($dir); } |
http://www.bkjia.com/PHPjc/631669.html www.bkjia.com true http://www.bkjia.com/PHPjc/631669.html techarticle The article is very simple two instances of PHP directory creation and recursive unlimited creation and deletion of the directory function, the need for friends can refer to, we use Mkdir,rddir to instance. Below ...