时间: 2020-09-3|tag:44次围观|0 条评论

php遍历路径——php经典实例

php遍历路径——php经典实例插图

 

代码:

<html>    <head>        <title>遍历目录</title>        <meta charset="utf-8" />    </head>        <body>        <h1>遍历目录</h1>        <table border='1' cellpadding='10' cellspacing='0'>            <tr>                <th>文件名</th>                <th>类型</th>                <th>大小</th>                <th>创建时间</th>            </tr>            <?php                //定义要遍历的路径                $dir="/";                                //打开路径返回句柄                $dd=opendir($dir);                                //遍历                while(false !== ($f=readdir($dd))){                    echo "<tr>";                    if($f=="." || $f==".."){                        continue;                    }                                        $file=rtrim($dir,"/")."/".$f;                    $f2=iconv("GB2312","UTF-8",$file);                    echo "<td>{$f2}</td>";                    echo "<td>".filetype($file)."</td>";                    echo "<td>".filesize($file)."</td>";                    echo "<td>".date("Ymd h:i",filectime($file))."</td>";                    echo "</tr>";                }                                //关闭句柄                closedir($dd);            ?>        </table>        </body></html>

 

文章转载于:https://www.cnblogs.com/wordblog/p/6850027.html

原著是一个有趣的人,若有侵权,请通知删除

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《php遍历路径——php经典实例
   

还没有人抢沙发呢~