Get the App
SLTechnology News&Howtos  ›  Development  › 

How PHP uses the readdir () function

Shulou Source: shulou.com Published: 2022-06-01 02:33:10 09月21日 Update

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!

Tags: Directory file function content article handle file name method this is learning help parameter easy to understand more organization item knowledge system tape industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Redmi MariaDB macOS Shulou Information