Check if current DirectoryIterator item is executable in PHP

Description

The following code shows how to check if current DirectoryIterator item is executable.

Example


//from  w w  w  .  jav  a2  s  .c  om
//This example lists files in the directory containing the script which are executable.
<?php
$iterator = new DirectoryIterator(dirname(__FILE__));
foreach ($iterator as $fileinfo) {
    if ($fileinfo->isExecutable()) {
        echo $fileinfo->getFilename() . "\n";
    }
}
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    File »




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