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 代码量而写的
如果您看了本篇博客,觉得对您有所收获,请点击右下角的 [推荐]
如果您想转载本博客,请注明出处
如果您对本文有意见或者建议,欢迎留言
感谢您的阅读,请关注我的后续博客