Home  >  Article  >  Backend Development  >  php无限遍历目录示例_php实例

php无限遍历目录示例_php实例

WBOY
WBOYOriginal
2016-05-17 08:48:58875browse

最近在能php目录操作,搞了一个目录无限遍历:

使用的函数有:

isset()判断某个变量是否定义

chdir() 将当前目录改变为指定的目录。

opendir() 打开目录。

readdir()读取目录。

getcwd()。获取当前目录。

还用到了for  if  GET传值 大概就这些东东:

下面是代码:

复制代码 代码如下:

if(isset($_GET['id']))
{

    $s=$_GET['id'];
        chdir($s);
    }
echo '当前在'.getcwd(),'
';
$a=opendir('.');
while($c=readdir($a))
{
    if(is_dir($c))
    {
        $w=getcwd().'\\'.$c;
    echo $c."打开
";
    }
    else
    {
            echo $c.'
';
     }

 }

?>


大家如果有什么建议可以提出来!!谢谢!!
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