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

How to scan all files in a directory_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:52:371052browse

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...
Statement:
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