Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8618179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:02:40+00:00 2026-06-12T06:02:40+00:00

PHP 5 introduced DirectoryIterator , and PHP 5.3 introduced FileSystemIterator . FileSystemIterator extends DirectoryIterator

  • 0

PHP 5 introduced DirectoryIterator, and PHP 5.3 introduced FileSystemIterator.

FileSystemIterator extends DirectoryIterator, but the documentation fails to say what extra features it brings.

Can you tell the difference between DirectoryIterator and FileSystemIterator?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:02:42+00:00Added an answer on June 12, 2026 at 6:02 am

    This goes out of the top of my head, where I sort of got caught in the changes prior to PHP 5.3 that were going to change in 5.3 and later, concerning the SPL (StandardPHPLibrary) and stuff that were going to be moved to the (horrible) PECL extensions.

    The major thing that changed since 5.3, was that the SPL became an extension that could not be disabled anymore, see the changelog of 5.3 noting that

    • Added SPL to list of standard extensions that cannot be disabled.
      (Marcus)

    so all the fancy classes like DirectoryIterator or SPLDoublyLinkedList were now a fix suite of classes that came with PHP 5.3.

    There were a lot of discussions going on that the DirectoryIterator was still very clumsy in iterating over files/directories and from behaviour not anonymous enough to the filesystem being used. Because depending on the filesystem (Windows NTFS / *nix EXTx) the results the iterator would return were different from another, where *nix environments per default always resulted the dot and double dot directories (. and ..) as valid directories. These dot directories could then be filtered in the loop by using the isDot() method.

    $it = new DirectoryIterator(__DIR__);
    foreach ($it as $fileinfo) {
      if (!$fileinfo->isDot())
        var_dump($fileinfo->getFilename());
    }
    

    So FilesystemIterator became the new parent class in PHP 5.3, which prior to its release was the DirectoryIterator (where FilesystemIterator extends DirectoryIterator to implement this interchangeable behaviour by default). The behaviour, or result the FilesystemIterator produced, would then be equal to all different filesystems and interchangeable without the need of any overhead in the loop

    $it = new FilesystemIterator(__DIR__);
    foreach ($it as $fileinfo) {
      echo $fileinfo->getFilename() . "\n";
    }
    

    It’s a good question why they didn’t update the documentation for noticing the user on the fact that actually the FilesystemIterator preceded the DirectoryIterator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile a list of features that were introduced in PHP 5.3.
PHP's mkdir returns false on failure. Failure can be: Folder already exists Some other
I've been digging in and learning as much as I can about PHP Arrays,
I am trying to use the normalizer_normalize() function introduced in PHP 5.3 (says the
I know that with PHP 4.1 they introduced the concept of super globals, which
Along with the introduction of Closures in PHP 5.3, has been introduced a getClosureThis()
My json_decode() is failing, but I can't call json_last_error() because that function isn't available
When was the strip_tags() function first introduced to PHP? Which version?
This seems so simple, but I can't figure it out... I would like all
PHP has PHP-FPM, a pool of PHP processes that run, are managed, go away

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.