廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 2503 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
tailin! 手機
個人頭像
個人文章 個人相簿 個人日記 個人地圖
小有名氣
級別: 小有名氣 該用戶目前不上站
推文 x0 鮮花 x13
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[PHP][教學] 計算你開發的 PHP 程式大小
說明 :
計算該目錄下的程式規模,包含檔案數,行數,字數

<?php
/************************************************************************/
/* AAPortal: Portal with Community and Commerce System             */
/* ===================================================             */
/*                                               */
/* Copyright (c) 2002-2004 by Shiner Technologies Co., Ltd.         */
/* http://shinersoft.com                                 */
/*                                               */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.     */
/************************************************************************/

/**
* 計算該目錄下的程式規模,包含檔案數,行數,字數
*
* @version 1.0
* @since 1.0
* @access public
* @author Ryan <ryan@shinersoft.com>
* @copyright Copyright (c) 2002-2004 by Shiner Technologies Co., Ltd.
* @package AAPortal
*/

// 請修改這個目錄的位置
$dir = "aaportal";


// 以下不用更動
$counts = array("directory" => 0, "file" => 0, "line" => 0, "size" => 0);

check($dir);

echo "Total:\n";
echo "Directry : ".$counts["directory"]."\n";
echo "File : ".$counts["file"]."\n";
echo "Line : ".$counts["line"]."\n";
echo "Size : ".$counts["size"]."\n";

function check($dir)
{
  global $counts;
 
  if ($dh = opendir($dir)) {
    while (($file = readdir($dh)) !== false) {
        if ($file == ".") continue;
        if ($file == "..") continue;
        if ($file == "CVS") continue;
        $path = $dir."/".$file;
        if (is_dir($path)) {
          $counts["directory"]++;
          //echo "dir ".$counts["directory"]." $path\n";
          check($path);
        } else {
          $ext = array_pop(explode('.', basename($path)));
          if ($ext=="php" || $ext=="inc") {
            $counts["file"]++;
            //echo "file ".$counts["file"]." $path\n";
            $lines = file($path);
            $counts["line"] += count($lines);
            $counts["size"] += filesize($path);
          }
        }
    }
    closedir($dh);
  }
} ?>



Best Regard ... \(^o^)/ ... ﹒‧°∴°﹒☆°.
獻花 x0 回到頂端 [樓 主] From:台灣新世紀資通 | Posted:2005-04-13 15:20 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.015357 second(s),query:15 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言