Friday, June 12, 2026
HomeLanguagesPHP | DirectoryIterator isLink() Function

PHP | DirectoryIterator isLink() Function

The DirectoryIterator::isLink() function is an inbuilt function in PHP which is used to check the current DirectoryIterator item is a symbolic link or not.

Syntax:

bool DirectoryIterator::isLink( void )

Parameters: This function does not accept any parameters.

Return Value: This function returns TRUE if the item is a symbolic link, otherwise returns FALSE.

Below programs illustrate the DirectoryIterator::isLink() function in PHP:

Program 1:




<?php
  
// Create a directory Iterator
$directory = new DirectoryIterator(dirname(__FILE__));
  
// Loop runs for each element of directory
foreach($directory as $dir) {
      
    // Use isLink() function to store the result
    $link = $dir->isLink();
      
    // Display result
    var_dump($link);
}
  
?>


Output:

bool(false)
bool(false)
bool(false)

Program 2:




<?php
   
// Create a directory Iterator
   
$directory = new DirectoryIterator(dirname(__FILE__));
   
// Loop runs while directory is valid
while ($directory->valid()) {
       
    // Use isLink() function to store the result
    $link = $directory->isLink();
       
    // Display result
    var_dump($link);
      
    $directory->next();
}
   
?>


Output:

bool(false)
bool(false)
bool(false)

Note: The output of this function depends on the content of server folder.

Reference: https://www.php.net/manual/en/directoryiterator.islink.php

RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS