Discover php delete all files and folders in directory, include the articles, news, trends, analysis and practical advice about php delete all files and folders in directory on alibabacloud.com
Sometimes we need to use php to delete all the files in the folder and its folder, so we can use the following code. For more information, see. Add features as required
The code is as follows:
Function deldir ($ dir ){
// Delete the files in the
Php deletes all folders and files in a path, and php deletes the path folder.
Php traverses all the files and folders in a folder, deletes the code of all the files in all the folders and subfolders, and uses recursion to clear a directory. The code
Php implements code for deleting and copying all files in folders and their folders. Copy the code as follows :? Php * copy xCopy function usage: * xCopy (feiy, feiy2, 1): copy the file in feiy to feiy2, including the sub-directory * xCopy (feiy,
/** * Delete all files under the folder and its folders */public static function Deldir ($dir) {//delete files in directory first: $dh =opendir ($dir); while ($file =readdir ($DH)) { if ($file! = "." && $file! = "...") {$fullpath = $dir. " /". $file,
Delete files and directories in PHP rmdir () function can be done, but to delete a non-empty directory, will not be able to quickly delete, you must first delete the directory files, but there may be subdirectories in the directory, so you want to
/**
* functions to read folders and files in them
* edit:bbs.it-home.org
*
*/
function Getfoldersandfiles ($resourceType, $currentFolder)
{
Map the virtual path to the local server path.
$sServerDir =
Use of the unlink () and rmdir () functions for deleting files and folders in PHP. Let's take a look at the code copy code as follows :? Functiondeldir ($ dir) {delete the files in the directory first: $ dhopendir ($ dir); while ($ filereaddir ($ dh)
Php deletes the function code of all files in the folder and its folder. Copy the code as follows :? Functiondeldir ($ dir) {delete the files in the directory first: $ dhopendir ($ dir); while ($ filereaddir ($ dh) {if ($ file !. $ File !..) {$
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.