欢迎来到福编程网,本站提供各种互联网专业知识!

計算你開發的 PHP 程式大小

发布时间:2006-12-06 作者: 来源:转载
复制代码代码如下:

复制代码 代码如下:

/**
*計算該目錄下的程式規模,包含檔案數,行數,字數
*
*@version1.0
*@since1.0
*@accesspublic
*@authorRyan
*@copyrightCopyright(c)2002-2004byShinerTechnologiesCo.,Ltd.
*@packageAAPortal
*/

//請修改這個目錄的位置
$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";

functioncheck($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"]."$pathn";
check($path);
}else{
$ext=array_pop(explode('.',basename($path)));
if($ext=="php"||$ext=="inc"){
$counts["file"]++;
//echo"file".$counts["file"]."$pathn";
$lines=file($path);
$counts["line"]+=count($lines);
$counts["size"]+=filesize($path);
}
}
}
closedir($dh);
}
}?>

相关推荐