$path=‘./phpMyAdmin‘;function showAll($path){ ???if(is_dir($path)){ ???????$handle=opendir($path); ???????//$file=readdir($handle); ???????为什么不能在外面读取目录句柄 ???????echo "<ul>"; ???????????????while(false !== ($file = readdir($handle))){ ???????????if($file==‘.‘ ||$file==‘..‘){ ???????????????continue; ???????????} ???????????echo "<li>".$file."</li>"; ???????????if(is_dir($path.‘/‘.$file)){ ???????????????showAll($path.‘/‘.$file); ???????????} ???????} ???????echo "</ul>"; ???????closedir($handle);//关闭目录句柄 ???}else{ ???????echo "不是目录"; ???}}showAll($path);
php递归遍历目录
原文地址:http://www.cnblogs.com/mengor/p/7774863.html