Home arrow PHP arrow 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.

  1. Using Introspective Methods with the DirectoryIterator Class in PHP 5
  2. The isDir() method
  3. Using the isDot() method
  4. Implementing the isExecutable(), isReadable() and isWritable() methods
  5. The getPerms() and getType() methods
By: Alejandro Gervasio
Rating: starstarstarstarstar / 5
September 25, 2006

print this article




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!

>>> More PHP Articles          >>> More By Alejandro Gervasio

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: