php 获取当前目录所有文件夹名 及下级目录文件夹名 求代码详解

如题所述

把这个文件放到\wamp\www\
这里,然后运行。
?php
if
(isset($_GET['dir'])){
//设置文件目录
$basedir=$_GET['dir'];
}else{
$basedir
=
'.';
}
checkdir($basedir);
function
checkdir($basedir)
{
if
($dh
=
opendir($basedir))
{
while
(($file
=
readdir($dh))
!==
false)
{
if
($file
!=
'.'
&&
$file
!=
'..'){
if
(!is_dir($basedir."/".$file))
{
echo
"filename:
$basedir/$file
";
}else{
$dirname
=
$basedir."/".$file;
checkdir($dirname);
}
}
}
closedir($dh);
}
}
?
[以下于为题无关]
吗蛋,代码前的空格都没了,这不是我去掉的哦,是百X把空格全去了,有强迫症表示不能接受啊...........
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网