<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Determine if current DirectoryIterator item is a symbolic link</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="directoryiterator.isfile.html">DirectoryIterator::isFile</a></div> <div class="next" style="text-align: right; float: right;"><a href="directoryiterator.isreadable.html">DirectoryIterator::isReadable</a></div> <div class="up"><a href="class.directoryiterator.html">DirectoryIterator</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="directoryiterator.islink" class="refentry"> <div class="refnamediv"> <h1 class="refname">DirectoryIterator::isLink</h1> <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">DirectoryIterator::isLink</span> — <span class="dc-title">Determine if current DirectoryIterator item is a symbolic link</span></p> </div> <div class="refsect1 description" id="refsect1-directoryiterator.islink-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>DirectoryIterator::isLink</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Determines if the current <a href="class.directoryiterator.html" class="classname">DirectoryIterator</a> item is a symbolic link. </p> </div> <div class="refsect1 parameters" id="refsect1-directoryiterator.islink-parameters"> <h3 class="title">Parameters</h3> <p class="para">This function has no parameters.</p> </div> <div class="refsect1 returnvalues" id="refsect1-directoryiterator.islink-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> if the item is a symbolic link, otherwise <strong><code>FALSE</code></strong> </p> </div> <div class="refsect1 examples" id="refsect1-directoryiterator.islink-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3864"> <p><strong>Example #1 A <span class="methodname"><strong>DirectoryIterator::isLink()</strong></span> example</strong></p> <div class="example-contents"><p> This example contains a recursive function for removing a directory tree. </p></div> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">/**<br /> * This function will recursively delete all files in the given path, without<br /> * following symlinks.<br /> * <br /> * @param string $path Path to the directory to remove.<br /> */<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">removeDir</span><span style="color: #007700">(</span><span style="color: #0000BB">$path</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">$dir </span><span style="color: #007700">= new </span><span style="color: #0000BB">DirectoryIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$path</span><span style="color: #007700">);<br /> foreach (</span><span style="color: #0000BB">$dir </span><span style="color: #007700">as </span><span style="color: #0000BB">$fileinfo</span><span style="color: #007700">) {<br /> if (</span><span style="color: #0000BB">$fileinfo</span><span style="color: #007700">-></span><span style="color: #0000BB">isFile</span><span style="color: #007700">() || </span><span style="color: #0000BB">$fileinfo</span><span style="color: #007700">-></span><span style="color: #0000BB">isLink</span><span style="color: #007700">()) {<br /> </span><span style="color: #0000BB">unlink</span><span style="color: #007700">(</span><span style="color: #0000BB">$fileinfo</span><span style="color: #007700">-></span><span style="color: #0000BB">getPathName</span><span style="color: #007700">());<br /> } elseif (!</span><span style="color: #0000BB">$fileinfo</span><span style="color: #007700">-></span><span style="color: #0000BB">isDot</span><span style="color: #007700">() && </span><span style="color: #0000BB">$fileinfo</span><span style="color: #007700">-></span><span style="color: #0000BB">isDir</span><span style="color: #007700">()) {<br /> </span><span style="color: #0000BB">removeDir</span><span style="color: #007700">(</span><span style="color: #0000BB">$fileinfo</span><span style="color: #007700">-></span><span style="color: #0000BB">getPathName</span><span style="color: #007700">());<br /> }<br /> }<br /> </span><span style="color: #0000BB">rmdir</span><span style="color: #007700">(</span><span style="color: #0000BB">$path</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">removeDir</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-directoryiterator.islink-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="methodname"><a href="directoryiterator.gettype.html" class="methodname" rel="rdfs-seeAlso">DirectoryIterator::getType()</a> - Determine the type of the current DirectoryIterator item</span></li> <li class="member"> <span class="methodname"><a href="directoryiterator.isdir.html" class="methodname" rel="rdfs-seeAlso">DirectoryIterator::isDir()</a> - Determine if current DirectoryIterator item is a directory</span></li> <li class="member"> <span class="methodname"><a href="directoryiterator.isdot.html" class="methodname" rel="rdfs-seeAlso">DirectoryIterator::isDot()</a> - Determine if current DirectoryIterator item is '.' or '..'</span></li> <li class="member"> <span class="methodname"><a href="directoryiterator.isfile.html" class="methodname" rel="rdfs-seeAlso">DirectoryIterator::isFile()</a> - Determine if current DirectoryIterator item is a regular file</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="directoryiterator.isfile.html">DirectoryIterator::isFile</a></div> <div class="next" style="text-align: right; float: right;"><a href="directoryiterator.isreadable.html">DirectoryIterator::isReadable</a></div> <div class="up"><a href="class.directoryiterator.html">DirectoryIterator</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>