php递归调用打印当前目录下的所有文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wtfsb/article/details/78340755

<?php

function showdir($path)
{
if (is_dir($path)){
  if ($dh = opendir($path)){
    while (($file = readdir($dh)) !== false){
if($file=="."||$file=="..")
{
continue;
}
echo "filename:" . $file . "<br>";
if(is_dir($path.'/'.$file))
      {
      showdir($path.'/'.$file);
      }
    }
    closedir($dh);
  }
}
}


showdir(".");

猜你喜欢

转载自blog.csdn.net/wtfsb/article/details/78340755