Home  >  Article  >  Backend Development  >  php browse directory_PHP tutorial

php browse directory_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:54:431381browse

The opendir() function opens a directory handle and 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 error output by prepending "@" to the function name.

php tutorial browse directory

The opendir() function opens a directory handle and can be used by closedir(), readdir() and rewinddir().

If successful, this function returns a directory stream, otherwise it returns false and an error. You can hide error output by prepending "@" to 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 browsing implementation and use the table to browse the structure of the directory

print("n");
//Create the header of the table
print("n");
print("
n");
print("
n");
print("
n");
$mydirectory = opendir("."); // Create a handle to the operating directory
// Read each sub-item in the directory
while($entryname = readdir($mydirectory))//Access each file in the directory through loop
{
Print("");
Print("");
Print("");
Print("n");
}
closedir($mydirectory); // Close the directory
print("
File nameFile size
$entryname");
Print(filesize($entryname));//Return file size
Print("
n");

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631727.htmlTechArticle The opendir() function opens a directory handle and can be used by closedir(), readdir() and rewinddir(). If successful, the function returns a directory stream, otherwise it returns false and an err...
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