PHP | DirectoryIterator getPerms() Function Last Updated : 07 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The DirectoryIterator::getPerms() function is an inbuilt function in PHP that is used to get the permissions of the current DirectoryIterator item. Syntax: int DirectoryIterator::getPerms( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the file permissions as a decimal integer. The below programs illustrate the DirectoryIterator::getPerms() function in PHP. Program 1: php <?php // Create a directory Iterator $directory = new DirectoryIterator(dirname(__FILE__)); // Loop runs while directory is valid while ($directory->valid()) { // If not a dot folder if (!$directory->isDot()) { $perms = substr(sprintf('%o', $directory->getPerms()), -4); // Display the filename with permission echo $directory->getFilename() . " " . " | Permission: " . $perms . "<br>"; } $directory->next(); } ?> Output: applications.html | Permission: 0666 bitnami.css | Permission: 0666 dashboard | Permission: 0777 favicon.ico | Permission: 0666 geeks.PNG | Permission: 0666 gfg.php | Permission: 0666 img | Permission: 0777 index.php | Permission: 0666 webalizer | Permission: 0777 xampp | Permission: 0777 Program 2: php <?php // Create a directory Iterator $directory = new DirectoryIterator(dirname(__FILE__)); // Loop runs for each element of directory foreach($directory as $dir) { // If not a dot folder if (!$dir->isDot()) { $perms = substr(sprintf('%o', $dir->getPerms()), -4); // Display the filename with permission echo $dir->getFilename() . " " . " | Permission: " . $perms . "<br>"; } } ?> Output: applications.html | Permission: 0666 bitnami.css | Permission: 0666 dashboard | Permission: 0777 favicon.ico | Permission: 0666 geeks.PNG | Permission: 0666 gfg.php | Permission: 0666 img | Permission: 0777 index.php | Permission: 0666 webalizer | Permission: 0777 xampp | Permission: 0777 Note: The output of this function depends on the content of the server folder. Comment More infoAdvertise with us Next Article PHP | DirectoryIterator getPerms() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Iterators Similar Reads PHP | DirectoryIterator getType() Function The DirectoryIterator::getType() function is an inbuilt function in PHP which is used to check the type of the current DirectoryIterator item. Syntax: string DirectoryIterator::getType( void ) Parameters: This function does not accept any parameters. Return Value: This function returns a string whic 2 min read PHP | DirectoryIterator getPath() Function The DirectoryIterator::getPath() function is an inbuilt function in PHP which is used to get the path of current Iterator item without filename. Syntax: string DirectoryIterator::getPath( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the file pa 2 min read PHP | DirectoryIterator getSize() Function The DirectoryIterator::getSize() function is an inbuilt function in PHP which is used to returns the size of the current DirectoryIterator item. Syntax: int DirectoryIterator::getSize( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the size of th 2 min read PHP | DirectoryIterator getATime() Function The DirectoryIterator::getATime() function is an inbuilt function in PHP which is used to get the last access time of the current DirectoryIterator item. Syntax: int DirectoryIterator::getATime( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the 2 min read PHP | DirectoryIterator getMTime() Function The DirectoryIterator::getMTime() function is an inbuilt function in PHP which is used to returns the last modification time of the current DirectoryIterator item. Syntax: int DirectoryIterator::getMTime( void ) Parameters: This function does not accept any parameters. Return Value: This function re 2 min read PHP | DirectoryIterator getCTime() Function The DirectoryIterator::getCTime() function is an inbuilt function in PHP which is used to get the inode change time of the current DirectoryIterator item. Syntax: int DirectoryIterator::getCTime( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the 2 min read PHP | DirectoryIterator getFilename() Function The DirectoryIterator::getFilename() function is an inbuilt function in PHP which is used to return file name of current DirectoryIterator item. Syntax: string DirectoryIterator::getFilename( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the fil 1 min read PHP | DirectoryIterator getPathname() Function The DirectoryIterator::getPathname() function is an inbuilt function in PHP which is used to return the path and file name of the current DirectoryIterator item. Syntax: string DirectoryIterator::getPathname( void ) Parameters: This function does not accept any parameters. Return Value: This functio 1 min read PHP | DirectoryIterator getBasename() Function The DirectoryIterator::getBasename() function is an inbuilt function in PHP which is used to get the base name of the current DirectoryIterator item. Syntax: string DirectoryIterator::getBasename( string $suffix ) Parameters: This function accepts single parameter $suffix which holds the base name e 2 min read PHP | DirectoryIterator next() Function The DirectoryIterator::next() function is an inbuilt function in PHP which is used to move forward to the next DirectoryIterator item. Syntax: void DirectoryIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below p 1 min read Like