php traverses all files and folders in a folder, and deletes the code of all files under all folders and subfolders, achieving the effect of emptying a directory through recursion .
Function used:
scandir($path)
Traverse all files in a folder and return an array. unlink($filename)
Delete the file. rmdir($path)
Delete only empty folders
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Recommended tutorial: "PHP Tutorial"
The above is the detailed content of How to delete a folder (containing the files in it) in php. For more information, please follow other related articles on the PHP Chinese website!