php无限遍历文件夹示例分享_PHP教程

WBOY
Release: 2016-07-13 10:37:10
Original
742 people have browsed it

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

使用的函数有:

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

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

opendi()打开目录。

readdir()读取目录。

getcwd()获取当前目录。

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

下面是代码:

复制代码代码如下:

if(isset($_GET['id']))//判断是否传值
{
$s=str_replace(' ','+',$_GET['id']);
$s=base64_decode($s);//接受传递的值 值一般是要打开的目录的绝对路劲
chdir($s);//切换到要打开的目录
}
$a=opendir('.');//打开当前目录
while(false!==($c=readdir($a)))//循环遍历目录内容的文件名
{
if(is_dir($c))//判断是目录还是文件
{
if($c=='.')
{
}
else
{
if($c=='..')
{
$w=base64_encode(substr(getcwd(),0,strrpos(getcwd(),'\\')));//当前路径加上目录名 就是目录的绝对路径
echo "上一级"." 打开
";//当点击打开时将要打开的绝对路径传递出去 用chdir 切换到要打开的目录下
}else
{
$w=base64_encode(getcwd().'\\'.$c);//当前路径加上目录名 就是目录的绝对路径
echo "$c"." 打开
";//当点击打开时将要打开的绝对路径传递出去 用chdir 切换到要打开的目录下
}
}
}
else
{
echo "$c 不是目录
";
}
}

?>

www.bkjia.com true http://www.bkjia.com/PHPjc/736803.html TechArticle 最近在能php目录操作,搞了一个目录无限遍历: 使用的函数有: isset()判断某个变量是否定义 chdir() 将当前目录改变为指定的目录。 opend...
Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!