Home >Backend Development >PHP Tutorial >再点一次Active的名,我把你的函数功能扩充了一下,嘻嘻,现在能_PHP

再点一次Active的名,我把你的函数功能扩充了一下,嘻嘻,现在能_PHP

WBOY
WBOYOriginal
2016-06-01 12:28:45833browse

把你的函数改写成递归函数,现在这个函数可以列出某指定目录内的所有文件及子目录内的文件啦。


function listdir($path)
{
   chdir($path);
   $d = dir($path);
   $d->path."
\n";
   print "

    ";
       while($entry=$d->read()){
            if ($entry"." and $entry".." ){
                $last=filemtime($entry);
                print "
  • ";
                $name=is_dir($entry)?("再点一次Active的名,我把你的函数功能扩充了一下,嘻嘻,现在能_PHP".$entry):("再点一次Active的名,我把你的函数功能扩充了一下,嘻嘻,现在能_PHP".$entry);
                print $name." --- ".date("Y/m/d h:i:s",$last);
                if (is_dir($path."/".$entry)){
                    listdir($path."/".$entry);
                }
            }
           }
       $d->close();
       print "
";
}

$listpath="c:";
echo $listpath;
listdir($listpath);

?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn