算你的 PHP 程式大小

复制代码 代码如下:<?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 程式大小,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。