FilesystemIterator::current
PHP function
Edit on GitHub ✎
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
The current file
Description
FilesystemIterator::current(): string|SplFileInfo|FilesystemIterator
Get file information of the current element.
Parameters Parameters
Return Values
The filename, file information, or $this depending on the set flags. See the FilesystemIterator constants.
Examples
FilesystemIterator::current example
This example will list the contents of the directory containing the script.
php
<?php
$iterator = new FilesystemIterator(__DIR__, FilesystemIterator::CURRENT_AS_PATHNAME);
foreach ($iterator as $fileinfo) {
echo $iterator->current() . "\n";
}
?>Similar
output
/www/examples/.
/www/examples/..
/www/examples/apple.jpg
/www/examples/banana.jpg
/www/examples/example.phpSee Also
- FilesystemIterator constants
DirectoryIterator::currentDirectoryIterator::getFileName