What exactly are the benefits of using a PHP 5 DirectoryIterator over PHP 4 “opendir/readdir/closedir”?

前端 未结 4 1291
迷失自我
迷失自我 2021-02-04 09:03

What exactly are the benefits of using a PHP 5 DirectoryIterator

$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $fileinfo) 
{
    // handle wh         


        
4条回答
  •  走了就别回头了
    2021-02-04 10:02

    It's shorter, cleaner and easier to type and read.

    Try re-read your examples. Just “for each in $dir in first example.

    What you want, that you write…

提交回复
热议问题