广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 2512 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为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.025740 second(s),query:15 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言