<?php
//遍历文件夹的内容
$path = '/opt/home';
list_dir($path);
function list_dir($path){
if(is_dir($path)){
$dh = opendir($path);
while(($file = readdir($dh)) !== false){
if(is_dir($path.'/'.$file) && $file!='..' && $file!='.'){
echo '目录'.$file.'<br>';
list_dir($path.'/'.$file);
} else{
if($file!='..' && $file!='.'){
echo '文件'.$path.'/'.$file.'<br>';
}
}
}
closedir($dh);
}
}
PHP遍历文件夹目录
最新推荐文章于 2021-04-15 13:46:36 发布