Home >Backend Development >PHP Tutorial >php reads all files in the specified directory

php reads all files in the specified directory

WBOY
WBOYOriginal
2016-07-25 08:45:461021browse
  1. $dir = "PUT_PATH_TO_DIR_HERE";
  2. // Open a known directory, and proceed to read its contents
  3. if (is_dir($dir)) {
  4. if ($dh = opendir($dir)) {
  5. while (($file = readdir($dh)) !== false) {
  6. echo "filename: $file : filetype: " . filetype($dir . $file) . "n";
  7. }
  8. closedir($dh);
  9. }
  10. }
  11. ?>
复制代码

目录下, php


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