<?php
header('Content-Type: text/html; charset=utf-8');
function read_dirs($path) {
// 判断path是否存在
if(!file_exists($path)){
var_dump([ 'code'=>'1001','msg' =>'path is not exits!']);
// 判断path是否为目录
}elseif (!is_dir($path)){
var_dump(['code' => '1002','msg' => 'is not dir' ]);
}else{
$dir_handle = opendir($path);
while(false !== $file=readdir($dir_handle)) {
if ($file=='.' || $file=='..') continue;
//输出该文件
// 判断当前file是否为目录
if(is_dir($path . '/' . $file)) {
// file为目录时进行递归遍历
// read_dirs($path . '/' . $file);
echo '<div class="col-md-4"><a class="list-group-item" href="'.$file.'" target="_blank">'.$file.'</a></div>';
}
}
closedir($dir_handle);
}
}
read_dirs('./');
?>
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询