Home  >  Article  >  Backend Development  >  PHP code to read all files in a directory_PHP tutorial

PHP code to read all files in a directory_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:54:20840browse

To read the code of all files in the directory, you can copy the code regardless of the file name

The code is as follows:

$dir = "file";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir( $dir)) {

while (($file = readdir($dh)) !== false) {
if ($file!="." && $file!=".." ) {
echo "".$file."
";
} }
} }
closedir($dh);
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318545.htmlTechArticleRead the code of all files in the directory. You can copy the code regardless of the file name. The code is as follows: ?php $dir=" file"; //Openaknowndirectory,andproceedtoreaditscontents if(is_dir($dir)){ if($dh=op...
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