Home > php教程 > PHP源码 > scandir得到该文件下的所有文件和文件夹

scandir得到该文件下的所有文件和文件夹

PHP中文网
Release: 2016-05-26 08:18:27
Original
1238 people have browsed it

php代码

<?php
$dir = "."; //当前目录
list_file($dir);

function list_file($dir){
	$list = scandir($dir); // scandir得到该文件下的所有文件和文件夹
	foreach($list as $file){//遍历
		$file_location=$dir."/".$file;//生成路径
		if(is_dir($file_location) && $file!="." &&$file!=".."){ //判断是不是文件夹
			echo "------------------------sign in $file_location------------------<BR>";
			list_file($file_location); //继续遍历
		}
		echo $dir."/".$file."<br/>";
	}
}
?>
Copy after login
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template