Home > Backend Development > PHP Tutorial > How to scan all files in a directory_PHP tutorial

How to scan all files in a directory_PHP tutorial

WBOY
Release: 2016-07-13 10:52:37
Original
1130 people have browsed it

How to scan all files in a directory?

List all html under a directory
Display as a link

// Note that !== did not exist until 4.0.0-RC2

if ($handle = opendir('/path/to/files')) {
echo "Directory handle: $handlen";
echo "Files:n";

/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$filen";
}

/* This is the WRONG way to loop over the directory. */
while ($file = readdir($handle)) {
echo "$filen";
}

closedir($handle);
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632468.htmlTechArticleHow to scan all the files in a directory and list all the html in a directory as links? php // Note that !== did not exist until 4.0.0-RC2 if ($handle = o...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template