<?php

function FileCount($dir){
    global $count;
    if(is_dir($dir)&&file_exists($dir)){
        $ob=scandir($dir);
        foreach($ob as $file){
            if($file=="."||$file==".."){
                continue;
            }
            $file=$dir."/".$file;
            if(is_file($file)){
                $count++;
            }elseif(is_dir($file)){
                FileCount($file);
            }
        }
    }
}

//调用方法
$count=0;
FileCount("DataRoom");
echo $count;exit;

PHP读取一个目录下的文件个数的更多相关文章

  1. SpringBoot读取资源目录下的文件

    需要读取resources目录下的文件,那么方法如下: 假设在资源目录下的template目录下有一个文件a.txt,获取到文件流的方式 InputStream stream = this.getCl ...

  2. iOS案例:读取指定目录下的文件列表

    // // main.m // 读取指定目录下的文件列表 // // Created by Apple on 15/11/24. // Copyright © 2015年 Apple. All rig ...

  3. Python 读取某个目录下的文件

    读取某个目录下的文件,如'/Users/test/test_kmls'目录下有test1.txt.test2.txt. 第一种方法读出的all_files是test1.txt.test2.txt im ...

  4. 如何用DOS命令,获取一个目录下的文件数目

    发信人: GOOGOODALLS (我爱Figo), 信区: DOS 标  题: 如何用DOS命令,获取一个目录下的文件数目? 发信站: 水木社区 (Fri Mar  9 08:40:01 2007) ...

  5. Python读取一个目录下的所有文件

    #!/usr/bin/python # -*- coding:utf8 -*- import os allFileNum = 0 def printPath(level, path): global ...

  6. python 读取一个目录下的所有目录和文件

    #!/usr/bin/python # -*- coding:utf8 -*- import os allFileNum = 0 def printPath(level, path): global ...

  7. [Java] 在 jar 文件中读取 resources 目录下的文件

    注意两点: 1. 将资源目录添加到 build path,确保该目录下的文件被拷贝到 jar 文件中. 2. jar 内部的东西,可以当作 stream 来读取,但不应该当作 file 来读取. 例子 ...

  8. linux 如何统计某目录下所有文件个数

    该目录以及该目录的子目录下普通文件个数: ls -lR |grep '^-' |wc -l ls -l 查询该目录下的所有文件 R 包含子目录,其实就是递归查看 grep '^-' 表示过滤掉(以&q ...

  9. Spring boot 读取resource目录下的文件

    背景:最近做项目重构将以前的ssh + angular js架构,重构为spring boot + vue.项目是一个数据管理平台,后台涉及到多表关联查询,数据导入导出等. 问题:读取resource ...

随机推荐

  1. SwipeRefreshLayout实现上拉加载下拉刷新

    package com.example.swiperefreshlayoutdemo; import java.util.ArrayList;import java.util.HashMap; imp ...

  2. 串口通信类,WPF

    参考之前的资料,写了一个自己常用的串口类, 字符串发送类型用了两种方式,char[] 和byte[] : 数据接收也是采用两种 char[] 和byte[] 两种. 类代码贴出来: public cl ...

  3. Using Amazon API Gateway with microservices deployed on Amazon ECS

    One convenient way to run microservices is to deploy them as Docker containers. Docker containers ar ...

  4. ios之无限图片轮播器的实现

    首先实现思路:整个collectionView中只有2个cell.中间始终显示第二个cell. 滚动:向前滚动当前cell的脚标为0,向后滚动当前的cell脚标为2.利用当前cell的脚标减去1,得到 ...

  5. PHP导出CSV UTF-8转GBK不乱码的解决办法

    折腾了几次 搜索了好久 终于找到办法 /** * http://yige.org/php/ * @ string 需要转换的文字 * @ encoding 目标编码 **/ function conv ...

  6. [Call Vibrator] How to Enable Outgoing Call Vibration without ROOT

    Call Vibrator requires the radio log of phone to detect when outgoing call is answered. But since An ...

  7. DTMF Stresstesting

    import threading,time,serial,sys from random import randrange   port_snd=14 port_recv=2 recnt=0 ser_ ...

  8. [原创]java WEB学习笔记71:Struts2 学习之路-- struts2常见的内建验证程序及注意点,短路验证,非字段验证,错误消息的重用

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  9. Node.js Express 获取request原始数据

    app.use(bodyParser.json());客户端请求接口时如果指名请求头类型 为Content-Type=application/jsonbodyParser 会自动将 body 里的 j ...

  10. -XX:+PrintGCTimeStamps 打印CG发生的时间戳

    -XX:+PrintGCTimeStamps –打印CG发生的时间戳   –[GC[DefNew: 4416K->0K(4928K), 0.0001897 secs] 4790K->374 ...