array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'directoryiterator.tostring.php', 1 => 'DirectoryIterator::__toString', ), 'up' => array ( 0 => 'class.directoryiterator.php', 1 => 'DirectoryIterator', ), 'prev' => array ( 0 => 'directoryiterator.seek.php', 1 => 'DirectoryIterator::seek', ), 'next' => array ( 0 => 'directoryiterator.valid.php', 1 => 'DirectoryIterator::valid', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/spl/directoryiterator/tostring.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
DirectoryIterator::__toString — Get file name as a string
Get the file name of the current DirectoryIterator item.
此函数没有参数。
Returns the file name of the current DirectoryIterator item.
示例 #1 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;
}
?>
以上示例的输出类似于:
. .. apple.jpg banana.jpg index.php pear.jpg