亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PHP統(tǒng)計(jì)代碼行數(shù)的小代碼

 更新時(shí)間:2019年09月19日 10:20:12   作者:子在夢(mèng)中曰  
這篇文章主要為大家詳細(xì)介紹了PHP統(tǒng)計(jì)代碼行數(shù)的小代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了PHP統(tǒng)計(jì)代碼行數(shù)的具體代碼,供大家參考,具體內(nèi)容如下

想統(tǒng)計(jì)一下項(xiàng)目中一共有多少行代碼,結(jié)果沒(méi)找到什么好的工具,就自己寫了一個(gè)。

效率不怎么樣。

<?php
/**
 * Created by PhpStorm.
 * User: luyanfeng
 * Date: 16/7/12
 * Time: 下午1:45
 */
 
/**
 * @param $dir
 * @return int
 */
function countLine($dir)
{
 $count = 0;
 if (is_dir($dir)) {
 $files = scandir($dir);
 foreach ($files as $file) {
 if ($file[0] == '.') continue;
 $file = $dir . "/" . $file;
 if (is_dir($file)) {
 $count += countLine($file . "/");
 } else {
 if (strpos($file, ".php"))
  $count += count(file($file));
 }
 }
 } else {
 $count += count(file($dir));
 }
 return $count;
}
 
if (count($argv) < 2) {
 echo "lack params\n";
 die;
}
$dir = $argv[1];
echo countLine($dir) . "\n";

在命令行中運(yùn)行,參數(shù)為要查詢的文件或者目錄的絕對(duì)路徑。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論