title: What exactly are the benefits of using a PHP 5 DirectoryIterator over PHP 4 "opendir/readdir/closedir"?
body: <p>What exactly are the benefits of using a PHP 5 DirectoryIterator</p>
  
  <pre><code>$dir = new DirectoryIterator(dirname(__FILE__));
  foreach ($dir as $fileinfo) 
  {
      // handle what has been found
  }
  </code></pre>
  
  <p>over a PHP 4 "opendir/readdir/closedir"</p>
  
  <pre><code>if($handle = opendir(dirname(__FILE__))) 
  {
      while (false !== ($file = readdir($handle))) 
      {
          // handle what has been found
      }
      closedir($handle);
  }
  </code></pre>
  
  <p>besides the subclassing options that come with OOP?</p>