PHP | DirectoryIterator isDot() Function
The DirectoryIterator::isDot() function is an inbuilt function in PHP which is used to check the current DirectoryIterator item is ‘.’ or ‘..’
Syntax:
bool DirectoryIterator::isDot( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns TRUE if the entry is . or .., otherwise FALSE.
Below programs illustrate the DirectoryIterator::isDot() function in PHP:
Program 1:
<?php
$directory = new DirectoryIterator(dirname( __FILE__ ));
foreach ( $directory as $dir ) {
if (! $dir ->isDot()) {
$perms = substr (sprintf( '%o' , $dir ->getPerms()), -4);
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
Sublime Text Build 3211 x64 Setup.exe | Permission: 0777
webalizer | Permission: 0777
xampp | Permission: 0777
Program 2:
<?php
$directory = new DirectoryIterator(dirname( __FILE__ ));
while ( $directory ->valid()) {
if (! $directory ->isDot()) {
echo $directory ->getFilename() . "<br>" ;
}
$directory ->next();
}
?>
|
Output:
applications.html
bitnami.css
dashboard
favicon.ico
geeks.PNG
gfg.php
img
index.php
Sublime Text Build 3211 x64 Setup.exe
webalizer
xampp
Note: The output of this function depends on the content of server folder.
Reference: https://www.php.net/manual/en/directoryiterator.isdot.php
Last Updated :
26 Nov, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...