统计目录行数
<?php
/**
* Created by PhpStorm.
* User: 21kr
* Date: 2019/3/18
* Time: 11:05
*/
class TongJi {
private static $line = 0;
private static $white_dir_list = ['storage', 'vendor', '.cache', 'node_modules', 'build', 'tests'];
public static function readDirLine($file) {
$list = scandir($file);
foreach ($list as $_file) {
if(is_dir($_file) && !in_array($_file, self::$white_dir_list) && strstr($_file, '.') === false) {
self::readDirLine($_file);
} else {
if(is_file($_file)) {
self::$line += count(file($_file));
}
}
}
return self::$line;
}
}
$line = TongJi::readDirLine('./');
网友评论