List the contents of the directory containing the script in PHP

Description

The following code shows how to list the contents of the directory containing the script.

Example


/*  w  w  w .j  av a  2  s . com*/
<?php
$iterator = new FilesystemIterator(dirname(__FILE__), FilesystemIterator::CURRENT_AS_PATHNAME);
foreach ($iterator as $fileinfo) {
    echo $iterator->current() . "\n";
}
?>




















Home »
  PHP Tutorial »
    File »




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