PHP
  Home arrow PHP arrow Main Methods of the DirectoryIterator Class in PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Main Methods of the DirectoryIterator Class in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    2006-09-11


    Table of Contents:
  • Main Methods of the DirectoryIterator Class in PHP 5
  • Why you should use the DirectoryIterator class: examining a concrete example
  • A standard way to traverse directories: using the DirectoryIterator class
  • A deeper look at the DirectoryIterator class: using the key() and current() methods
  • Resetting a directory’s internal pointer: the rewind() method

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Main Methods of the DirectoryIterator Class in PHP 5
    ( Page 1 of 5 )

    The DirectoryIterator class is an important part of the Standard PHP Library (SPL). Among other things, it lets you traverse any specified directory with a regular "foreach" loop. In this first article of a three-part series, some of the most relevant methods that come with the “DirectoryIterator” class are covered.

    Introduction

    During your productive life as PHP developer, you’ve quite possibly found yourself “reinventing the wheel” many times, particularly in those cases where you needed to develop certain modules of an application from scratch. Yeah, I know what this means, since I’ve done the same thing frequently, and it often happens that one doesn’t feel confident enough to delegate the control and programming of the application to third-party software packages.

    Even now, when things are radically different (at least to me), since I’m using well-trusted PHP classes, the truth is that developing something that has been already created by someone else happens very often. However, with the introduction of the Standard PHP Library (SPL), hopefully these programming habits will start to change.

    Among the numerous and cool features introduced within the SPL package, there’s one that I found especially appealing, because it has become a real time saver in many situations. I’m talking about the set of iterating classes, aimed at traversing different data structures, that is arrays, files, objects and so forth, by using a simple “foreach” language construct.

    If you’ve already tasted the power of at least one of these classes, then you know what I mean, because no matter what elements you work with, they can be iterated by the same interface. This is particularly useful when using the “DirectoryIterator” class, which is an important part of the SPL package. Obviously, as its name suggests, this class not only will allow you to traverse any directory by utilizing a regular “foreach” loop, but it will also let you handle information related to the directory in question, by using a few straightforward methods.

    Because this class might be handy to use in projects where handling directories is a must, in this new series I’ll be taking a close look at some of its most important methods. We will explore these methods appropriately in conjunction with the corresponding code samples. Therefore, get ready to see the real power of this class. Let’s begin this journey right now!



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

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT