In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to delete a directory with php". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Php delete directory methods: 1, create a PHP sample file; 2, find the directory to be deleted; 3, use the rmdir () function to delete the specified directory.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
How does php delete a directory?
PHP rmdir (): delete a directory
Similar to normal files, you can delete a directory if you confirm that it will no longer be used. You can use the rmdir () function in PHP to delete a specified directory, and the syntax format of this function is as follows:
Rmdir (string $dirname [, resource $context])
Where the parameter $dirname is the directory path to be deleted, and $context is an optional parameter that specifies the environment of the file handle.
Note: when you delete a specified directory using the rmdir () function, the directory must be empty and have the appropriate permissions. The function returns TRUE when it succeeds, and FALSE if it fails. Deleting a directory that is not empty will also generate an E_WERNING-level error.
[example] use the rmdir () function to delete the specified directory.
To run the above code, first make sure that the test directory is empty, otherwise the following error will occur:
Warning: rmdir (. / test): Directory not empty in D:\ WWW\ index.php on line 4
What should I do if I want to delete a directory that is not empty? We can iterate through all the files and folders in this directory and delete them one by one recursively. The following is demonstrated by the sample code:
This is the end of the content of "how to delete directories with php". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.