โ— Shell
clean mode source โ†—

PHP: FilesystemIterator::__construct - Manual

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

FilesystemIterator::__construct โ€” Constructs a new filesystem iterator

Description

public function FilesystemIterator::__construct(string $directory, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS)

Examples

Example #1 FilesystemIterator::__construct() example

<?php
$it = new FilesystemIterator(dirname(__FILE__), FilesystemIterator::CURRENT_AS_FILEINFO);
foreach ($it as $fileinfo) {
    echo $fileinfo->getFilename() . "\n";
}
?>

Output of the above example in PHP 8.2 is similar to:

.
..
apples.jpg
banana.jpg
example.php

Output of the above example prior to PHP 8.2.0 is similar to:

apples.jpg
banana.jpg
example.php

See Also

Found A Problem?

There are no user contributed notes for this page.