zoukankan      html  css  js  c++  java
  • php 计算代码行数

    <?php 
    header("Content-type:text/html;charset=utf-8");
    
    // php 递归计算文件夹代码行数
    function codeLine($file){
    	return count(file($file));
    }
    error_reporting(0); // 屏蔽notice 错误
    $lines = 0;
    
    function forDir($path){
    	
    	if(!is_dir($path)){
    		return null;
    	}
    	// $arr 数组里面放你要计算文件的后缀
    	$arr = array("php");
    	$dh = opendir($path);
    	while(($dir = readdir($dh)) !== false){
    		if($dir != "." && $dir != ".."){
    			if(is_dir($path . "/" . $dir)){
    				$lines += forDir($path . "/" . $dir);
    			}else{
    				foreach($arr as $v){
    					if(str_replace(".","",strrchr($dir,".")) == $v){
    						$lines += codeLine($path . "/" . $dir);
    					}
    				}
    			}
    		}
    	}
    	closedir($dh);
    	return $lines;
    }
    

     为了计算 Thinkphp 代码量而写的

    如果您看了本篇博客,觉得对您有所收获,请点击右下角的 [推荐]

    如果您想转载本博客,请注明出处

    如果您对本文有意见或者建议,欢迎留言

    感谢您的阅读,请关注我的后续博客

  • 相关阅读:
    搜索1011
    搜索1008(二分)
    贪心算法专题总结
    贪心算法1002
    c++笔记
    贪心算法1017
    贪心算法1008
    贪心算法1013
    Ubuntu中 sudo update与sudo upgrade的作用及区别
    requirejs 扩展,支持脚本资源预加载
  • 原文地址:https://www.cnblogs.com/geek12/p/4215880.html
Copyright © 2011-2022 走看看