Thursday, December 18, 2025
HomeLanguagesPHP | FilesystemIterator getFlags() Function

PHP | FilesystemIterator getFlags() Function

The FilesystemIterator::getFlags() function is an inbuilt function in PHP which is used to get the handling flags.

Syntax:

int FilesystemIterator::getFlags( void )

Parameters: This function does not accept any parameters.

Return Value: This function returns an integer value representing the set of flags.

Below programs illustrate the FilesystemIterator::getFlags() function in PHP:

Program 1:




<?php
  
// Create new file system iterator
$fileItr = new FilesystemIterator(__DIR__, 
    FilesystemIterator::CURRENT_AS_PATHNAME);
  
// Store the flag 
$flag = $fileItr->getFlags(); 
    
// Display the flag 
var_dump($flag); 
  
?>


Output:

int(4128)

Program 2:




<?php
  
// Create new file system iterator
$fileItr = new FilesystemIterator(__DIR__, 
    FilesystemIterator::CURRENT_AS_PATHNAME);
  
// Set the flag
$fileItr->setFlags(FilesystemIterator::KEY_AS_FILENAME);
  
// Get the flag 
$flag = $fileItr->getFlags(); 
    
// Display the flag 
var_dump($flag); 
  
?>


Output:

int(256)

Reference: https://www.php.net/manual/en/filesystemiterator.getflags.php

RELATED ARTICLES

Most Popular

Dominic
32455 POSTS0 COMMENTS
Milvus
108 POSTS0 COMMENTS
Nango Kala
6823 POSTS0 COMMENTS
Nicole Veronica
11958 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12037 POSTS0 COMMENTS
Shaida Kate Naidoo
6958 POSTS0 COMMENTS
Ted Musemwa
7203 POSTS0 COMMENTS
Thapelo Manthata
6911 POSTS0 COMMENTS
Umr Jansen
6890 POSTS0 COMMENTS