(PHP 5, PHP 7)
Determine if current DirectoryIterator item is a symbolic link
public bool DirectoryIterator::isLink ( void )
Determines if the current DirectoryIterator item is a symbolic link.
Returns:
Returns TRUE
if the item is a symbolic link, otherwise FALSE
Examples:
A DirectoryIterator::isLink() example
This example contains a recursive function for removing a directory tree.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?php /** * This function will recursively delete all files in the given path, without * following symlinks. * * @param string $path Path to the directory to remove. */ function removeDir( $path ) { $dir = new DirectoryIterator( $path ); foreach ( $dir as $fileinfo ) { if ( $fileinfo ->isFile() || $fileinfo ->isLink()) { unlink( $fileinfo ->getPathName()); } elseif (! $fileinfo ->isDot() && $fileinfo ->isDir()) { removeDir( $fileinfo ->getPathName()); } } rmdir ( $path ); } removeDir( 'foo' ); ?> |
See also:
Please login to continue.