PHP code to read all files in a directory_PHP tutorial

WBOY
Release: 2016-07-21 15:54:20
Original
875 people have browsed it

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!