DirectoryIterator::isLink
DirectoryIterator::isLink
(PHP 5, PHP 7)
DirectoryIterator :: isLink - 确定当前的DirectoryIterator项目是否是符号链接
Description
public bool DirectoryIterator::isLink ( void )
确定当前的DirectoryIterator项是否是符号链接。
Parameters
该功能没有参数。
Return Values
如果项目是符号链接则返回TRUE
,否则返回FALSE
Examples
Example #1 A DirectoryIterator::isLink() example
此示例包含用于删除目录树的递归函数。
<?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'
?>
← DirectoryIterator::isFile
DirectoryIterator::isReadable →
© 1997–2017 The PHP Documentation Group
根据知识共享署名许可证v3.0或更高版本授权。