計(jì)算你開發(fā)的 PHP 程式大小
更新時(shí)間:2006年12月06日 00:00:00 作者:
復(fù)制代碼 代碼如下:
<?php
/**
* 計(jì)算該目錄下的程式規(guī)模,包含檔案數(shù),行數(shù),字?jǐn)?shù)
*
* @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
*/
// 請(qǐng)修改這個(gè)目錄的位置
$dir = "aaportal";
// 以下不用更動(dòng)
$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);
}
} ?>
/**
* 計(jì)算該目錄下的程式規(guī)模,包含檔案數(shù),行數(shù),字?jǐn)?shù)
*
* @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
*/
// 請(qǐng)修改這個(gè)目錄的位置
$dir = "aaportal";
// 以下不用更動(dòng)
$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);
}
} ?>
相關(guān)文章
基于PHP Web開發(fā)MVC框架的Smarty使用說明
本篇文章小編為大家介紹,基于PHP Web開發(fā)MVC框架的Smarty使用說明。需要的朋友參考下2013-04-04PHP學(xué)習(xí)記錄之面向?qū)ο螅∣bject-oriented programming,OOP)基礎(chǔ)【接口、抽象類、靜態(tài)方法等
這篇文章主要介紹了PHP學(xué)習(xí)記錄之面向?qū)ο螅∣bject-oriented programming,OOP)基礎(chǔ),結(jié)合實(shí)例形式分析了PHP面向?qū)ο蟪绦蛟O(shè)計(jì)中接口、抽象類、靜態(tài)方法等相關(guān)概念、原理、用法與操作注意事項(xiàng),需要的朋友可以參考下2019-12-12php中實(shí)現(xiàn)簡(jiǎn)單的ACL 完結(jié)篇
終于寫完了 呵呵 簡(jiǎn)單的一個(gè)實(shí)現(xiàn),學(xué)習(xí)php的朋友可以參考下。2011-09-09自編函數(shù)解決pathinfo()函數(shù)處理中文問題
本文主要介紹了小編在使用pathinfo()函數(shù)處理中文文件名時(shí)遇到的一個(gè)小BUG的處理方式,有相同問題的童鞋們可以參考下2014-11-11PHP手機(jī)號(hào)中間四位用星號(hào)*代替顯示的實(shí)例
本篇文章主要介紹了PHP手機(jī)號(hào)中間四位用星號(hào)*代替顯示的實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06Thinkphp模板中截取字符串函數(shù)簡(jiǎn)介
在php中截取字符串的函數(shù)有很多,而在thinkphp中也可以直接使用php的函數(shù),本文給大家簡(jiǎn)單的介紹thinkPHP模板中截取字符串的具體用法,希望能對(duì)各位有所幫助2014-06-06