Home  >  Article  >  Backend Development  >  Detailed explanation of how to use PHP to list all files under a directory_PHP Tutorial

Detailed explanation of how to use PHP to list all files under a directory_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:04:32960browse

Give the source code directly:

Copy the code The code is as follows:

$current_dir = 'E: /temp/';
$dir = opendir($current_dir);
echo "direcotry list:
    ";
    while(false !== ($file=readdir($dir)) ){
    if($file != "." && $file != ".."){
    echo "
  • $file
  • ";
    }
    }
    echo "
";
closedir($dir);

If it is the same drive letter as the web, just write: $current_dir='/temp/ ';That's it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327776.htmlTechArticle gives the source code directly: Copy the code as follows: $current_dir = 'E:/temp/'; $dir = opendir($current_dir); echo "direcotry list:ul"; while(false !== ($file=readdir($dir))){ if($f...
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