HomePHP Using Introspective Methods with the DirectoryIterator Class in PHP 5
Using Introspective Methods with the DirectoryIterator Class in PHP 5
If you’re one of those PHP developers who want to explore the package of classes that come bundled with the Standard PHP Library (SPL), then fear not, because you’re at the right place. Welcome to the concluding part of the series "A Close Look at the DirectoryIterator Class in PHP 5." In three parts, this series introduces the most important methods attached to this class, and shows you how to use them by mean of extensive hands-on examples.
After this short introduction, allow me to recapitulate briefly the topics that I covered in the two previous articles. This will conveniently refresh your memory and get you back into the flow of the contents of this series.
As you'll probably remember, over the course of the first article, I took an in-depth look at some of the core methods included within the "DiretoryIterator" class to demonstrate how a specified directory can be quickly traversed by a regular "foreach" language construct. In all the code samples that you saw, once an instance of the iterator class was properly created, the process for iterating over several directory entries was simplified to using the mentioned loop structure, in conjunction with a conventional array notation.
Aside from depicting the entire process for traversing a given directory and accessing each of its elements, in the second part of this series, strong emphasis was put on covering some of the most relevant methods that come with the "DirectoryIterator" class. In accordance with this, you learned how to do all sorts of clever things, like finding paths and names of directory entries, as well as handling the corresponding timestamps.
Perhaps you think that after having examined all the methods that I mentioned before, the tale of the "DirectoryIterator" class was already concluded. Well, not so fast; this class still has some additional methods that require special attention. For this reason, this last tutorial of the series will be focused mostly on covering all the methods related to performing some kind of introspective process, which can be quite useful when analyzing the types and permissions of each entry included in a given directory.
Having established the goals of this tutorial, let's get started. Hopefully, this will be an educational experience!