列出目录中的所有文件,更多信息即将到来

编程入门 行业动态 更新时间:2024-10-24 06:32:02
本文介绍了列出目录中的所有文件,更多信息即将到来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的代码-

if ($handle = opendir('banner/')) { while (false !== ($file = readdir($handle))) { echo "$file"; } closedir($handle); }

当我运行此代码时,不必要的点(.)就要来了. 输出image-3.jpgimage-4.jpgimage-1.jpgimage-2.jpgimage-5.jpg...为什么最后有3个点?

wher I run this code unnecessary dots(.) are coming. output image-3.jpgimage-4.jpgimage-1.jpgimage-2.jpgimage-5.jpg... why 3 dots are coming at the last??

推荐答案

因为.是当前目录,而..是父目录.

Because . is the current directory and .. is the parent directory.

它们始终存在.

如果您需要排除它们-只需添加

If you need to exclude them - just add

if ($file != '.' && $file != '..')

在echo

更多推荐

列出目录中的所有文件,更多信息即将到来

本文发布于:2023-10-25 21:54:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1528217.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:更多信息   文件   目录中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!