Recently, when processing planning resource files, you need to synchronize all the files in directory A to the files in directory B and delete all the unnecessary files in directory B. Therefore, you can use the -- delete parameter of rsync to
PHP Read Directory Delete (can delete directory files) This article provides a PHP directory management program, he can be in the directory of files, folders, and other files for the management of delete operations, can support the management of an
deleting files and directories in PHP is actually very simple as long as two functions one is unlink a rmdir function, if you want to implement delete directories and directories under the file we need to use the recursive operation.
Function code:
In daily operations, we often use rsync as a synchronization artifact. Sometimes when synchronizing two directories, it is required to delete files in the target directory that are more than the source directory, in which case the--delete parameter
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
Delete all files in directory and directory * DEL_DIR (deleted path, 1 means delete directory data, 0 default delete this directory);
Delete all files in directory and directory* DEL_DIR (delete the path, 1 means delete the directory under the data,
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
//Loop Delete directory and file function delete all files in directory and directory Public Static functionDeldirandfile ($dirName ) { //Var_dump (Is_dir ($dirName)); exit; if($handle=Opendir( "$dirName" ) ) { while(
Translated from: http://www.tqcto.com/article/recommend/142.htmlFunction: Delete all subdirectories and files in a directory and directory knowledge point: File.delete () used to remove "A file or empty directory" ! So to delete a directory and all
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.