Home > Backend Development > PHP Tutorial > PHP readdir function

PHP readdir function

WBOY
Release: 2016-07-29 09:12:37
Original
1083 people have browsed it

 Recently, I am learning the relevant knowledge of PHP file operations. I will record one of the points to pay attention to in the readdir() function

1. In the $temp=readdir($handle) function, readdir obtains the file name and the file in $handle. Folder name,

  Usually in the program, files are traversed through a while() loop:

         while($temp=readdir($handel)){}
Copy after login

  But there is a problem with the judgment statement of this way of writing: if there is a folder with a name of '0' under $handle, then $temp=0, the while loop cannot continue, then the remaining files cannot be traversed, resulting in incorrect program results,

                                                                                                                                     

The above has introduced the readdir function of PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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