Get file name as a string in PHP

Description

The following code shows how to get file name as a string.

Example


/*w  w  w  .j  a  v a2  s. c  o m*/
//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 code above generates the following result.





















Home »
  PHP Tutorial »
    File »




Directory
DirectoryIterator
Drive
File
File Permission
File Read Save
FileSystemIterator
Path
Zip