The Opendir () function opens a directory handle that can be used by Closedir (), Readdir (), and Rewinddir (). If successful, the function returns a directory stream, otherwise it returns false and an error. You can hide the output of the error by adding "@" before the function name.
PHP Tutorials Browse Directories
The Opendir () function opens a directory handle that can be used by Closedir (), Readdir (), and Rewinddir ().
If successful, the function returns a directory stream, otherwise it returns false and an error. You can hide the output of the error by adding "@" before the function name.
*/
$dir = Opendir ("Images");
List files in the images directory
while (($file = Readdir ($dir))!== false)
{
echo "FileName:". $file. "
";
}
Closedir ($dir);
Take a look at the modified directory browse implementation, use the table to browse the structure of the directory
Print ("
n ");//Create the header of the table print ("
n ");p rint ("
filename | n ");p rint ("
size of File | n ");p rint ("
n "); $mydirectory = Opendir (". "); Create a handle to the operation directory//read out each subkey in the directory while ($entryname = Readdir ($mydirectory))//Through the loop, access each file of the directory {print ("
"); Print ("
$entryname | "); Print ("
"); Print (FileSize ($entryname));//Return file size Print (" | "); Print ("
n ");} Closedir ($mydirectory); Close the catalog print ("
n ");
http://www.bkjia.com/PHPjc/631727.html www.bkjia.com true http://www.bkjia.com/PHPjc/631727.html techarticle The opendir () function opens a directory handle that can be used by Closedir (), Readdir (), and Rewinddir (). If successful, the function returns a directory stream, otherwise it returns false as well as an err ...