Change language

PHP FileystemIterator __construct () Function

Syntax:
public FilesystemIterator::__ construct (string $path, int  $flags)
Parameters:This function takes two parameters as above and described below:
  • $path: this parameter contains the path to the file system element.
  • $flags:this parameter contains a flag that provides the influence and behavior of some methods.
Returned value:this function does not return any value.The following programs illustrate the FilesystemIterator::__ construct() function in PHP:Program 1:  
// Create a new file system iterator $fileItr =
new FilesystemIterator (dirname ( __ FILE__ ));  
// the loop starts for each element of the file system foreach ( $fileItr as $file ) { // Show file name echo $file -> getFilename(). "
"
; }
?>
Output:
applications.html bitnami.css dashboard favicon.ico engineer.PNG gfg.php img index.php Sublime Text Build 3211 x64 Setup.exe webalizer xampp
Program 2:   // Create a new file system iterator $fileItr = new FilesystemIterator (dirname ( __ FILE__ ));  
// Loop starts while the file iterator is active while ( $fileItr -> valid()) { // Check catalog files if ( $fileItr -> isDir()) { // Show filename echo $fileItr -> getFilename(). "
"
; } // Move to next item $fileItr -> next(); }  
?>
Output:
dashboard img webalizer xampp
Note . The output of this function depends on the contents of the server folder.Link: https : //www.php.net/manual/en/filesystemiterator.construct.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method