当前位置: 移动技术网 > IT编程>开发语言>PHP > 計算你開發的 PHP 程式大小

計算你開發的 PHP 程式大小

2019年06月08日  | 移动技术网IT编程  | 我要评论

粉泥网,井冈山机场到茨坪,好看的小说下载

复制代码 代码如下:
<?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);   
    }   
} ?> 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网