How PHP uses the readdir () function
This article mainly shows you how to use the readdir() function in PHP. The content is simple and easy to understand. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn how to use the readdir() function in PHP.
readdir ();--reads entries from directory handles
string readdir ([ resource $dir_handle ] )//Returns the filename of the next file in the directory. File names are returned in order in the file system.
Parameter: dir_handle Resource of directory handle, previously opened by opendir()
header("Content-Type:Text/html; charset=utf8"); if ($handle = opendir('d:/test')) { echo "Directory handle: $handle\n"; echo "Files:\n"; /* This is the correct directory traversal method */ while (false !== ($file = readdir($handle))) { echo "$file\n"; } /* This is the wrong way to traverse directories while ($file = readdir($handle)) { echo "$file\n"; } */ closedir($handle);} The above is "How to use the readdir() function in PHP". Thank you for reading it! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!