Example code for php opendir() to list all files in a directory

高洛峰
Release: 2023-03-03 18:10:01
Original
1093 people have browsed it

php opendir()函数用于打开目录,通常与readdir()和closedir()函数一起用来读取目录下所有文件(即遍历目录),本文章向大家介绍php使用opendir()函数列出目录下所有文件的实例。

实例一:

使用opendir()列出目录下所有文件

";
     exit;
   }
 
   while(($files[] = readdir($dr)) !== false);
 
   print_r($files);
?>
Copy after login

实例二:

列出目录下所有文件

$file";
  }
 }
 closedir( $dir );
?>
 

 
 列出目录下所有文件
 
 
 

Files in

Copy after login

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

更多php opendir()列出目录下所有文件的实例代码相关文章请关注PHP中文网!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!