DirectoryIterator::__toString

(PHP 5, PHP 7)
Get file name as a string
public string DirectoryIterator::__toString ( void )

Get the file name of the current DirectoryIterator item.

Returns:

Returns the file name of the current DirectoryIterator item.

Examples:
A DirectoryIterator::__toString() example

This example will list the contents of the directory containing the script.

<?php
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $fileinfo) {
    echo $fileinfo;
}
?>

The above example will output something similar to:

.
..
apple.jpg
banana.jpg
index.php
pear.jpg
See also:

DirectoryIterator::getFilename() -

__toString() -

doc_php
2016-02-24 16:19:50
Comments
Leave a Comment

Please login to continue.