Home >Backend Development >PHP Tutorial >PHP readdir function

PHP readdir function

WBOY
WBOYOriginal
2016-07-29 09:12:371102browse

 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)){}

  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.

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
Previous article:nginx php configurationNext article:nginx php configuration