Recently I am learning the relevant knowledge of PHP file operations, and 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 folder name in $handle,
Generally, in a program, files are traversed through a while() loop:
while($temp=readdir($handel)){}
But there is a problem with the judgment statement written in this way: if there is a folder with the name '0' under $handle, then $temp=0, the while loop cannot proceed, and then the remaining files cannot be traversed. , resulting in incorrect program results,
Correct writing:
while(($temp=readdir($handel))!==false){}//用不全等于是区分如果文件夹名字为0的时候,那么0!==false,仍然可以遍历