Click on the banner to learn about and purchase my database training on Azure

Removing all files from a directory with PHP

Views: 404 views
Reading Time: 2 minutes

Good night!

This time I come to comment on a problem that bothered me a little bit in PHP whenever I needed to delete a directory and it contained files. As you know, the function rmdir does not delete directories if files exist. Well, let's work on a solution for this:

Some functions of this class I already mentioned in the post Listing files with PHP, such as the listFiles and the extension handle. Therefore, I will focus on the new functions. Using the class is quite simple for our problem:

That's it!
See you!