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.