<?php
header("content-type:text/html;charset=utf-8");
//读取f:/hello下所有文件及文件夹名称(包括子目录)
function hello($path)
{
$fileList = scandir($path);
foreach ($fileList as $file) // $file 看作元素理解
{
if($file!=="." && $file!=="..")
{
$a = is_file("{$path}/{$file}");
if($a)//文件
{
echo "{$file}<br>";
}
else//文件夹
{
//echo "<a style=\"color:red\">{$file}--->folder</a><br/>";
//显示当前文件夹下的所有文件及文件夹
hello("{$path}/{$file}");//****** ====-----> $file 从上往下看,它是作为判断,如果不为文件则为文件夹并输出其名字,并再次进行扫描文件夹,遍历文件输入其名字
echo <<<ZZG
<html>
<head>
<title>hello</title>
</head>
<body>
<a style=\"color:red\">{$file}--->folder</a><br/>
</body>
</html>
ZZG;
}
}
}
}
hello("C:/xampptest/htdocs/user"); // ===> 调用函数
?>
header("content-type:text/html;charset=utf-8");
//读取f:/hello下所有文件及文件夹名称(包括子目录)
function hello($path)
{
$fileList = scandir($path);
foreach ($fileList as $file) // $file 看作元素理解
{
if($file!=="." && $file!=="..")
{
$a = is_file("{$path}/{$file}");
if($a)//文件
{
echo "{$file}<br>";
}
else//文件夹
{
//echo "<a style=\"color:red\">{$file}--->folder</a><br/>";
//显示当前文件夹下的所有文件及文件夹
hello("{$path}/{$file}");//****** ====-----> $file 从上往下看,它是作为判断,如果不为文件则为文件夹并输出其名字,并再次进行扫描文件夹,遍历文件输入其名字
echo <<<ZZG
<html>
<head>
<title>hello</title>
</head>
<body>
<a style=\"color:red\">{$file}--->folder</a><br/>
</body>
</html>
ZZG;
}
}
}
}
hello("C:/xampptest/htdocs/user"); // ===> 调用函数
?>