php读取目录所有文件信息dir示例

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

<?php
set_time_limit(0);
function tree($directory)
{
$mydir=dir($directory);
echo "<ul> ";
while($file=$mydir->read()){
if((is_dir("$directory/$file")) AND ($file!=".") AND ($file!=".."))
{
echo "<li><font color='#ff00cc'><b>$file</b></font></li> ";
tree("$directory/$file");
}
else
{
echo "<li>$file</li> ";
}
}
echo "</ul>
";
$mydir->close();
}
//start the program
echo "<h2>目录为粉红色</h2>
";
tree(".");
?>

相关文章

PHP聚合式迭代器接口IteratorAggregate用法分析

本文实例讲述了PHP聚合式迭代器接口IteratorAggregate用法。分享给大家供大家参考,具体如下: PHP IteratorAggregate又叫聚合式迭代器,它提供了创建外部...

SSI指令

什么是 SHTML 使用SSI(Server Side Include)的html文件扩展名,SSI(Server Side Inclu...

PHP 创建文件(文件夹)以及目录操作代码

一、目录操作 首先是从目录读取的函数,opendir(),readdir(),closedir(),使用的时候是先打开文件句柄,而后迭代列出: 复制代码 代码如下: <?php $...

setcookie中Cannot modify header information-headers already sent by错误的解决方法详解

复制代码 代码如下:<?php   setcookie("username","bu",time()+3600);   echo "aaaa...

PHP随机数 C扩展随机数

PHP随机数 C扩展随机数

由于要用到固定长度的随机字符串。 首先是一段PHP代码 $str_md5=md5(uniqid()); $rand = mt_rand(1, 28); $str1=substr(...