php显示当前文件所在的文件以及文件夹所有文件


<div>
<?php
$path = "./";
function createDir($path = '.')
{
if ($handle = opendir($path))
{
echo "<ul>";
while (false !== ($file = readdir($handle)))
{
if (is_dir($path.$file) && $file != '.' && $file !='..')
printSubDir($file, $path, $queue);
else if ($file != '.' && $file !='..')
$queue[] = $file;
}
printQueue($queue, $path);
echo "</ul>";
}
}
function printQueue($queue, $path)
{
foreach ($queue as $file)
{
printFile($file, $path);
}
}
function printFile($file, $path)
{
echo "<li><a href=https://www.jb51.net/article/\"".$path.$file."https://www.jb51.net/article/\">$file</a></li>";
}
function printSubDir($dir, $path)
{
echo "<li><span class=https://www.jb51.net/article/\"toggle\">$dir</span>";
createDir($path.$dir."https://www.jb51.net/");
echo "</li>";
}
createDir($path);
?>
</div>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdwdsw.html