Home >Backend Development >PHP Tutorial >Example analysis of the total number of files and lines of code in the PHP statistics directory

Example analysis of the total number of files and lines of code in the PHP statistics directory

黄舟
黄舟Original
2017-08-21 10:43:581639browse

PHP counts the total number of files and lines of code in the directory, and executes the statistics of files in the directory

When skipping files: the matching rules only start from the file name, and the matching rules are also limited to beginning.

Skip comment lines in the file: The matching rules are only matched from the head of the comment paragraph. If // and *, lines starting with # and /* and blank lines appear, they will be skipped. Therefore, sweaty comments like /* must be preceded by an * sign at the beginning of each line, otherwise such comments cannot be matched.

Directory filtering: The matching rule is to match the full name of the directory name

First download the total number of files and lines of code in the PHP statistics directory we need to use for this course Several categories: http://www.php.cn/xiazai/leiku/542

After the download is complete, find the php class file we need, unzip it to our local directory, and create a new php file!

After completion, we need to call this class in the new php file and instantiate the class:

<?php
include_once "wenjian.php";//引入类文件
$obj = new caculatefiles();//实例化
//如果设置为false,这不会显示每个文件的信息,否则显示
$obj->setshowflag(false);
//会跳过所有all开头的文件
$obj->setfileskip(array(&#39;all&#39;));
$obj->run("D:/phpStudy/WWW/cv");

//所有文件,(默认格式为.php)
$obj->setfileskip(array());
$obj->run("D:/phpStudy/WWW/cv");

$obj->setshowflag(true);
//跳过所有i和a开头的文件,(比如接口和抽象类开头)
$obj->setfileskip(array(&#39;i&#39;, &#39;a&#39;));
$obj->run("D:/phpStudy/WWW/cv");
?>

The running result is as shown below:

Example analysis of the total number of files and lines of code in the PHP statistics directory

The above is the detailed content of Example analysis of the total number of files and lines of code in the PHP statistics directory. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn