页面导航: 首页网络编程PHP编程php实例 → 正文内容 計算你開發的 PHP 程式大小

計算你開發的 PHP 程式大小

发布:dxy 字体:[增加 减小] 类型:转载

<?php   
/**   
* 計算該目錄下的程式規模,包含檔案數,行數,字數   
*   
* @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);   
    }   
} ?> 

浏览次数:载入中... 打印本文关闭本文返回首页
·在百度中搜索关于“計算你開發的 PHP 程式大小”相关内容
·在谷歌中搜索关于“計算你開發的 PHP 程式大小”相关内容

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行