好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > PHP實現(xiàn)統(tǒng)計代碼行數(shù)小工具

PHP實現(xiàn)統(tǒng)計代碼行數(shù)小工具

熱門標簽:外呼系統(tǒng)撥打暫時無法接通 長春人工外呼系統(tǒng)服務商 仁和怎么申請400開頭的電話 哪里辦理400電話 高德地圖標注家 江西手機自動外呼防封系統(tǒng)是什么 怎么向銷售公司推銷外呼系統(tǒng) 廣東地市地圖標注 廣州防封卡外呼系統(tǒng)多少錢一個月

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

為了方面統(tǒng)計編程代碼行數(shù),做了一個小工具。

自動統(tǒng)計指定目錄以及目錄下的所有文件。

?php
 
class TotalCode {
 
 /**
 * 統(tǒng)計當前文件有多少行代碼,
 * @return TotalCodeInfo
 */
 public function totalByFile($fullFileName) {
 $fileContent = file_get_contents($fullFileName);
 $lines = explode("\n", $fileContent);
 $lineCount = count($lines);
 
 for($i = $lineCount -1; $i > 0; $i -= 1) {
  $line = $lines[$i];
  if ($line != "") break;
  $lineCount -= 1; //最后幾行是空行的要去掉。
 }
 unset($fileContent);
 unset($lines);
 
 $totalCodeInfo = new TotalCodeInfo();
 $totalCodeInfo->setFileCount(1);
 $totalCodeInfo->setLineCount($lineCount);
 return $totalCodeInfo;
 }
 
 /**
 * 統(tǒng)計當前目錄下(含子目錄)
 * 有多少文件,以及多少行代碼
 * 
 * totalInfo = array( "fileCount"=>?, "lineCount"=>? );
 * 
 * @return TotalCodeInfo 
 */
 public function totalByDir($dirName) {
 $fileList = scandir($dirName);
 $totalCodeDir = new TotalCodeInfo();
 foreach ($fileList as $fileName) {
  if ($fileName == "." || $fileName == "..") continue;
  $fullFileName = $dirName . "/" . $fileName;
  if (is_file($fullFileName)) {
  $totalCodeSub = $this->totalByFile($dirName . "/" . $fileName);
  } else if (is_dir($fullFileName)) {
  $totalCodeSub = $this->totalByDir($dirName . "/" . $fileName); 
  } else {
  $totalCodeSub = new TotalCodeInfo();
  }
  
  $totalCodeDir->increaseByOther($totalCodeSub);
 }
 return $totalCodeDir;
 }
 
 public function totalByDirOrFile($dirOrFileName) {
 if (is_dir($dirOrFileName)) {
  return $this->totalByDir($dirOrFileName);
 } else if (is_file($dirOrFileName)) {
  return $this->totalByFile($dirOrFileName);
 } else {
  return new TotalCodeInfo();
 }
 }
 
 public function test() {
 $re = $this->totalByDir("/export/www/pm_web/configs");
 var_dump($re);
 }
 
 public function main($dirList) {
 $totalCodeAll = new TotalCodeInfo();
 foreach($dirList as $dirName) {
  $totalCodeSub = $this->totalByDirOrFile($dirName);
  $totalCodeAll->increaseByOther($totalCodeSub);
 }
 print_r($totalCodeAll);
 }
 
}
 
class TotalCodeInfo {
 private $fileCount = 0;
 private $lineCount = 0;
 
 public function getFileCount() { return $this->fileCount; }
 public function getLineCount() { return $this->lineCount; }
 public function setFileCount($fileCount) {
 $this->fileCount = $fileCount;
 return $this;
 }
 public function setLineCount($lineCount) {
 $this->lineCount = $lineCount;
 return $this;
 }
 
 /**
 * 累加 
 */
 public function increaseByOther($totalCodeInfo) {
 $this->setFileCount( $this->fileCount + $totalCodeInfo->getFileCount());
 $this->setLineCount( $this->lineCount + $totalCodeInfo->getLineCount());
 return $this;
 }
}
 
$dirList = array();
$dirList[] = "/your/path";
 
$obj = new TotalCode();
$obj->main($dirList);

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • PHP統(tǒng)計代碼行數(shù)的小代碼
  • php 廣告點擊統(tǒng)計代碼(php+mysql)
  • php+memcache實現(xiàn)的網(wǎng)站在線人數(shù)統(tǒng)計代碼
  • php利用cookie實現(xiàn)訪問次數(shù)統(tǒng)計代碼
  • PHP遞歸統(tǒng)計系統(tǒng)中代碼行數(shù)

標簽:黔東 文山 海北 湘西 惠州 梅河口 廈門 濮陽

巨人網(wǎng)絡通訊聲明:本文標題《PHP實現(xiàn)統(tǒng)計代碼行數(shù)小工具》,本文關鍵詞  PHP,實現(xiàn),統(tǒng)計,代碼,行數(shù),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關。
  • 相關文章
  • 下面列出與本文章《PHP實現(xiàn)統(tǒng)計代碼行數(shù)小工具》相關的同類信息!
  • 本頁收集關于PHP實現(xiàn)統(tǒng)計代碼行數(shù)小工具的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 啊啊啊啊啊快| wang老王视频| 嗯~啊~轻一点????酒店| 放荡的护士3| 岳的下面好紧好爽视频| 夜夜夜精品视频免费| 性色av浪潮av色欲av一区| 色哟哟视频在线| 男生和女生差来差去的app大全下载| 亚洲好穴| 91在线精品无码秘?入口| 久久天天躁狠狠躁夜夜躁| 二次元人物去掉所有服装后的照片| ? ??色? 网? 站女男| 激情五月播播| 国产无套抽出白浆来| 顶级肉欲(高H、纯肉故事集| 国产又黄又爽的视频| 野外女人乱人伦| 掀起王钟瑶贵妇旗袍的裙子| b站禁止转播404直播541| 免费无码婬AAAA片在线漫画| 日本女同性恋| 办公室的呻吟声| 妞干网手机免费视频| 国模白灵大尺度啪啪人体| 美女扒开胸罩??给男生图片 | 男人的??伸到??里擼擼视频| 我把同桌操了| 可以直接看黄的网站| 女婴从小喂精养成H| 国产精品午夜爽欧美大片午夜爽| 男女边摸边吃奶动态图免费观看| 天天色影网| 成熟日本语热亚洲人| 得得爱免费视频| 国产精品高潮呻吟久久AV郑州| 91九色熟女| 草留视频| 被修理工侵犯的漂亮人妻| 尤物在线观看精品国产福利片|