• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • DirectoryIterator::next()

    (PHP 5,PHP 7)

    Move forward to next DirectoryIterator item

    说明

    publicDirectoryIterator::next(void) : void

    Move forward to the nextDirectoryIteratoritem.

    参数

    此函数没有参数。

    返回值

    没有返回值。

    范例

    Example#1DirectoryIterator::next()example

    List the contents of a directory using a while loop.

    <?php
    $iterator = new DirectoryIterator(dirname(__FILE__));
    while($iterator->valid()) {
        echo $iterator->getFilename() . "\n";
        $iterator->next();
    }
    ?>
    

    以上例程的输出类似于:

    .
    ..
    apple.jpg
    banana.jpg
    index.php
    pear.jpg
    

    参见

    • DirectoryIterator::current() Return the current DirectoryIterator item
    • DirectoryIterator::key() Return the key for the current DirectoryIterator item
    • DirectoryIterator::rewind() Rewind the DirectoryIterator back to the start
    • DirectoryIterator::valid() Check whether current DirectoryIterator position is a valid file
    • Iterator::next() 向前移动到下一个元素