A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 董事长 中级黑马   /  2016-11-20 15:37  /  1823 人查看  /  0 人回复  /   1 人收藏 转载请遵从CC协议 禁止商业使用本文

<?php
        header('Content-type:text/html;charset=utf-8');
        //定义一个变量,将要遍历的文件目录
        $dir = "D:\E";
        function showInfo($dir){
                //递归出口
                if(!is_dir($dir)){
                        return;
                }
                //scandir — 列出指定路径中的文件和目录
                $files = scandir($dir);
                foreach ($files as $v) {
                        //拼接
                        $file = $dir.'/'.$v;
                        if($v != '.' && $v != '..'){
                                if(is_dir($file)){
                                        echo "<font color='gray'>".$v."</font><br/>";
                                        //递归点
                                        showInfo($file);
                                }else{
                                        echo "<font color='blue'>".$v."</font><br/>";
                                }
                        }
                }
        }
        showInfo($dir);

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马